Skip to content

Commit 4d07e59

Browse files
authored
Merge pull request #13 from Nullify-Platform/azure-pr-comment
Azure pr comment
2 parents 53694f8 + 3350fd1 commit 4d07e59

File tree

6 files changed

+135
-12
lines changed

6 files changed

+135
-12
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Require labels to be added to a PR before merging
2+
# This is configured as a branch protection setting
3+
name: CI Require Labels
4+
on:
5+
pull_request:
6+
types: [opened, labeled, unlabeled, synchronize]
7+
merge_group:
8+
run-name: CI Require Labels ${{ github.sha }} by @${{ github.actor }}
9+
jobs:
10+
require-labels:
11+
if: ${{ github.event_name == 'pull_request' }}
12+
runs-on: ubuntu-latest
13+
outputs:
14+
status: ${{ steps.require-labels.outputs.status }}
15+
steps:
16+
- uses: actions/checkout@v3
17+
- name: Require Labels
18+
id: require-labels
19+
uses: nullify-platform/github-actions/actions/require-labels@main

.github/workflows/release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Create Release
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
releaseType:
6+
description: Create a draft release
7+
required: true
8+
type: boolean
9+
default: true
10+
push:
11+
branches:
12+
- main
13+
concurrency:
14+
group: release
15+
cancel-in-progress: false
16+
run-name: Release ${{ github.sha }} by @${{ github.actor }}
17+
permissions:
18+
contents: write
19+
id-token: write
20+
pull-requests: read
21+
jobs:
22+
get-version:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
version: ${{ steps.get-version.outputs.version }}
26+
steps:
27+
- uses: actions/checkout@v3
28+
- name: Get Release Version
29+
id: get-version
30+
uses: nullify-platform/github-actions/actions/release-version@main
31+
- run: |
32+
echo "config-file-parser @ ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
33+
echo "VERSION: ${{ steps.get-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY
34+
echo "SHORT_SHA: $(git rev-parse --short HEAD)" >> $GITHUB_STEP_SUMMARY
35+
release:
36+
if: ${{ needs.get-version.outputs.version != 'undefined' || (github.event_name == 'workflow_dispatch' && needs.get-version.outputs.version != 'undefined') }}
37+
runs-on: ubuntu-latest
38+
needs: [ get-version ]
39+
steps:
40+
- uses: actions/checkout@v3
41+
- name: Generate Release Tag
42+
run: echo "RELEASE_TAG=v${{ needs.get-version.outputs.version }}" >> $GITHUB_ENV
43+
- name: Generate Release
44+
uses: softprops/action-gh-release@v1
45+
with:
46+
draft: false
47+
generate_release_notes: true
48+
append_body: true
49+
tag_name: ${{ env.RELEASE_TAG }}
50+
token: ${{ secrets.GITHUB_TOKEN }}

azuredevops/azuredevops.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const (
2727
GitPullRequestUpdatedEventType Event = "git.pullrequest.updated"
2828
GitPullRequestMergedEventType Event = "git.pullrequest.merged"
2929
GitPushEventType Event = "git.push"
30+
GitPullRequestCommentEventType Event = "ms.vss-code.git-pullrequest-comment-event"
3031
)
3132

3233
// Webhook instance contains all methods needed to process events
@@ -74,6 +75,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error)
7475
var fpl BuildCompleteEvent
7576
err = json.Unmarshal([]byte(payload), &fpl)
7677
return fpl, err
78+
case GitPullRequestCommentEventType:
79+
var fpl GitPullRequestCommentEvent
80+
err = json.Unmarshal([]byte(payload), &fpl)
81+
return fpl, err
7782
default:
7883
return nil, fmt.Errorf("unknown event %s", pl.EventType)
7984
}

azuredevops/payload.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ type GitPushEvent struct {
5151
Scope string `json:"scope"`
5252
}
5353

54+
// "ms.vss-code.git-pullrequest-comment-event"
55+
56+
type GitPullRequestCommentEvent struct {
57+
ID string `json:"id"`
58+
EventType Event `json:"eventType"`
59+
PublisherID string `json:"publisherId"`
60+
Scope string `json:"scope"`
61+
Message Message `json:"message"`
62+
Resource PullRequestComment `json:"resource"`
63+
}
64+
5465
// build.complete
5566

5667
type BuildCompleteEvent struct {
@@ -100,6 +111,22 @@ type PullRequest struct {
100111
URL string `json:"url"`
101112
}
102113

114+
type PullRequestComment struct {
115+
PullRequest PullRequest `json:"pullRequest"`
116+
Comment Comment `json:"comment"`
117+
}
118+
119+
type Comment struct {
120+
ID int `json:"id"`
121+
ParentCommentID int `json:"parentCommentId"`
122+
Content string `json:"content"`
123+
Author User `json:"author"`
124+
PublishedDate Date `json:"publishedDate"`
125+
LastUpdatedDate Date `json:"lastUpdatedDate"`
126+
LastContentUpdatedDate Date `json:"lastContentUpdatedDate"`
127+
CommentType string `json:"commentType"`
128+
}
129+
103130
type Repository struct {
104131
ID string `json:"id"`
105132
Name string `json:"name"`

github/payload.go

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,39 @@ type CheckRunPayload struct {
216216
type CheckSuitePayload struct {
217217
Action string `json:"action"`
218218
CheckSuite struct {
219-
ID int64 `json:"id"`
220-
NodeID string `json:"node_id"`
221-
HeadBranch string `json:"head_branch"`
222-
HeadSHA string `json:"head_sha"`
223-
Status string `json:"status"`
224-
Conclusion string `json:"conclusion"`
225-
URL string `json:"url"`
226-
Before string `json:"before"`
227-
After string `json:"after"`
228-
PullRequests []PullRequestPayload `json:"pull_requests"`
229-
App struct {
219+
ID int64 `json:"id"`
220+
NodeID string `json:"node_id"`
221+
HeadBranch string `json:"head_branch"`
222+
HeadSHA string `json:"head_sha"`
223+
Status string `json:"status"`
224+
Conclusion string `json:"conclusion"`
225+
URL string `json:"url"`
226+
Before string `json:"before"`
227+
After string `json:"after"`
228+
PullRequests []struct {
229+
URL string `json:"url"`
230+
ID int64 `json:"id"`
231+
Number int64 `json:"number"`
232+
Head struct {
233+
Ref string `json:"ref"`
234+
SHA string `json:"sha"`
235+
Repo struct {
236+
ID int64 `json:"id"`
237+
URL string `json:"url"`
238+
Name string `json:"name"`
239+
} `json:"repo"`
240+
} `json:"head"`
241+
Base struct {
242+
Ref string `json:"ref"`
243+
SHA string `json:"sha"`
244+
Repo struct {
245+
ID int64 `json:"id"`
246+
URL string `json:"url"`
247+
Name string `json:"name"`
248+
} `json:"repo"`
249+
} `json:"base"`
250+
} `json:"pull_requests"`
251+
App struct {
230252
ID int64 `json:"id"`
231253
NodeID string `json:"node_id"`
232254
Owner struct {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module github.com/go-playground/webhooks/v6
1+
module github.com/nullify-platform/webhooks
22

33
go 1.17
44

0 commit comments

Comments
 (0)