diff --git a/.github/workflows/ci-require-labels.yml b/.github/workflows/ci-require-labels.yml new file mode 100644 index 0000000..6883a87 --- /dev/null +++ b/.github/workflows/ci-require-labels.yml @@ -0,0 +1,19 @@ +# Require labels to be added to a PR before merging +# This is configured as a branch protection setting +name: CI Require Labels +on: + pull_request: + types: [opened, labeled, unlabeled, synchronize] + merge_group: +run-name: CI Require Labels ${{ github.sha }} by @${{ github.actor }} +jobs: + require-labels: + if: ${{ github.event_name == 'pull_request' }} + runs-on: ubuntu-latest + outputs: + status: ${{ steps.require-labels.outputs.status }} + steps: + - uses: actions/checkout@v3 + - name: Require Labels + id: require-labels + uses: nullify-platform/github-actions/actions/require-labels@main \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bd94205 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,50 @@ +name: Create Release +on: + workflow_dispatch: + inputs: + releaseType: + description: Create a draft release + required: true + type: boolean + default: true + push: + branches: + - main +concurrency: + group: release + cancel-in-progress: false +run-name: Release ${{ github.sha }} by @${{ github.actor }} +permissions: + contents: write + id-token: write + pull-requests: read +jobs: + get-version: + runs-on: ubuntu-latest + outputs: + version: ${{ steps.get-version.outputs.version }} + steps: + - uses: actions/checkout@v3 + - name: Get Release Version + id: get-version + uses: nullify-platform/github-actions/actions/release-version@main + - run: | + echo "config-file-parser @ ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY + echo "VERSION: ${{ steps.get-version.outputs.version }}" >> $GITHUB_STEP_SUMMARY + echo "SHORT_SHA: $(git rev-parse --short HEAD)" >> $GITHUB_STEP_SUMMARY + release: + if: ${{ needs.get-version.outputs.version != 'undefined' || (github.event_name == 'workflow_dispatch' && needs.get-version.outputs.version != 'undefined') }} + runs-on: ubuntu-latest + needs: [ get-version ] + steps: + - uses: actions/checkout@v3 + - name: Generate Release Tag + run: echo "RELEASE_TAG=v${{ needs.get-version.outputs.version }}" >> $GITHUB_ENV + - name: Generate Release + uses: softprops/action-gh-release@v1 + with: + draft: false + generate_release_notes: true + append_body: true + tag_name: ${{ env.RELEASE_TAG }} + token: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/azuredevops/azuredevops.go b/azuredevops/azuredevops.go index 460cae4..c031759 100644 --- a/azuredevops/azuredevops.go +++ b/azuredevops/azuredevops.go @@ -28,6 +28,7 @@ const ( GitPullRequestUpdatedEventType Event = "git.pullrequest.updated" GitPullRequestMergedEventType Event = "git.pullrequest.merged" GitPushEventType Event = "git.push" + GitPullRequestCommentEventType Event = "ms.vss-code.git-pullrequest-comment-event" ) // Option is a configuration option for the webhook @@ -104,6 +105,10 @@ func (hook Webhook) Parse(r *http.Request, events ...Event) (interface{}, error) var fpl BuildCompleteEvent err = json.Unmarshal([]byte(payload), &fpl) return fpl, err + case GitPullRequestCommentEventType: + var fpl GitPullRequestCommentEvent + err = json.Unmarshal([]byte(payload), &fpl) + return fpl, err default: return nil, fmt.Errorf("unknown event %s", pl.EventType) } diff --git a/azuredevops/payload.go b/azuredevops/payload.go index 8554752..ec56834 100644 --- a/azuredevops/payload.go +++ b/azuredevops/payload.go @@ -51,6 +51,17 @@ type GitPushEvent struct { Scope string `json:"scope"` } +// "ms.vss-code.git-pullrequest-comment-event" + +type GitPullRequestCommentEvent struct { + ID string `json:"id"` + EventType Event `json:"eventType"` + PublisherID string `json:"publisherId"` + Scope string `json:"scope"` + Message Message `json:"message"` + Resource PullRequestComment `json:"resource"` +} + // build.complete type BuildCompleteEvent struct { @@ -100,6 +111,22 @@ type PullRequest struct { URL string `json:"url"` } +type PullRequestComment struct { + PullRequest PullRequest `json:"pullRequest"` + Comment Comment `json:"comment"` +} + +type Comment struct { + ID int `json:"id"` + ParentCommentID int `json:"parentCommentId"` + Content string `json:"content"` + Author User `json:"author"` + PublishedDate Date `json:"publishedDate"` + LastUpdatedDate Date `json:"lastUpdatedDate"` + LastContentUpdatedDate Date `json:"lastContentUpdatedDate"` + CommentType string `json:"commentType"` +} + type Repository struct { ID string `json:"id"` Name string `json:"name"` diff --git a/github/payload.go b/github/payload.go index 2f1cc84..902add2 100644 --- a/github/payload.go +++ b/github/payload.go @@ -216,17 +216,39 @@ type CheckRunPayload struct { type CheckSuitePayload struct { Action string `json:"action"` CheckSuite struct { - ID int64 `json:"id"` - NodeID string `json:"node_id"` - HeadBranch string `json:"head_branch"` - HeadSHA string `json:"head_sha"` - Status string `json:"status"` - Conclusion string `json:"conclusion"` - URL string `json:"url"` - Before string `json:"before"` - After string `json:"after"` - PullRequests []PullRequestPayload `json:"pull_requests"` - App struct { + ID int64 `json:"id"` + NodeID string `json:"node_id"` + HeadBranch string `json:"head_branch"` + HeadSHA string `json:"head_sha"` + Status string `json:"status"` + Conclusion string `json:"conclusion"` + URL string `json:"url"` + Before string `json:"before"` + After string `json:"after"` + PullRequests []struct { + URL string `json:"url"` + ID int64 `json:"id"` + Number int64 `json:"number"` + Head struct { + Ref string `json:"ref"` + SHA string `json:"sha"` + Repo struct { + ID int64 `json:"id"` + URL string `json:"url"` + Name string `json:"name"` + } `json:"repo"` + } `json:"head"` + Base struct { + Ref string `json:"ref"` + SHA string `json:"sha"` + Repo struct { + ID int64 `json:"id"` + URL string `json:"url"` + Name string `json:"name"` + } `json:"repo"` + } `json:"base"` + } `json:"pull_requests"` + App struct { ID int64 `json:"id"` NodeID string `json:"node_id"` Owner struct { @@ -4852,16 +4874,20 @@ type PullRequestReviewPayload struct { type PullRequestReviewCommentPayload struct { Action string `json:"action"` Comment struct { - URL string `json:"url"` - ID int64 `json:"id"` - NodeID string `json:"node_id"` - DiffHunk string `json:"diff_hunk"` - Path string `json:"path"` - Position int64 `json:"position"` - OriginalPosition int64 `json:"original_position"` - CommitID string `json:"commit_id"` - OriginalCommitID string `json:"original_commit_id"` - User struct { + URL string `json:"url"` + ID int64 `json:"id"` + NodeID string `json:"node_id"` + DiffHunk string `json:"diff_hunk"` + Path string `json:"path"` + Line int64 `json:"line"` + OriginalLine int64 `json:"original_line"` + StartLine int64 `json:"start_line"` + OriginalStartLine int64 `json:"original_start_line"` + Position int64 `json:"position"` + OriginalPosition int64 `json:"original_position"` + CommitID string `json:"commit_id"` + OriginalCommitID string `json:"original_commit_id"` + User struct { Login string `json:"login"` ID int64 `json:"id"` NodeID string `json:"node_id"` diff --git a/gitlab/payload.go b/gitlab/payload.go index 446a237..4b394d4 100644 --- a/gitlab/payload.go +++ b/gitlab/payload.go @@ -730,6 +730,7 @@ type ObjectAttributes struct { Target Target `json:"target"` LastCommit LastCommit `json:"last_commit"` Assignee Assignee `json:"assignee"` + DiscussionID string `json:"discussion_id"` // thread id } // PipelineObjectAttributes contains pipeline specific GitLab object attributes information diff --git a/go.mod b/go.mod index bb0fa5a..c502a46 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/go-playground/webhooks/v6 +module github.com/nullify-platform/webhooks go 1.17