Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(NODE-5768): add comment trigger for release notes #638

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 32 additions & 1 deletion .github/workflows/release_notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,44 @@ on:
description: 'Enter release PR number'
required: true
type: number
issue_comment:
types: [created]

permissions:
contents: write
pull-requests: write

jobs:
release_notes:
runs-on: ubuntu-latest
# Run only if dispatched or comment on a pull request
if: ${{ github.event_name == 'workflow_dispatch' || (github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.body == 'run release_notes') }}
steps:
# Determine if the triggering_actor is allowed to run this action
# We only permit maintainers
# Not only is 'triggering_actor' common between the trigger events it will also change if someone re-runs an old job
- name: check if triggering_actor is allowed to generate notes
env:
GITHUB_TOKEN: ${{ github.token }}
COMMENTER: ${{ github.triggering_actor && github.triggering_actor || 'empty_triggering_actor' }}
API_ENDPOINT: /repos/${{ github.repository }}/collaborators?permission=maintain
shell: bash
run: |
if [ $COMMENTER = "empty_triggering_actor" ]; then exit 1; fi
set -o pipefail
if gh api "$API_ENDPOINT" --paginate --jq ".[].login" | grep -q "^$COMMENTER\$"; then
echo "$COMMENTER permitted to trigger notes!" && exit 0
else
echo "$COMMENTER not permitted to trigger notes" && exit 1
fi

# checkout the HEAD ref from prNumber
- uses: actions/checkout@v3
with:
ref: refs/pull/${{ github.event_name == 'issue_comment' && github.event.issue.number || inputs.releasePr }}/head


# Setup Node.js and npm install
- name: actions/setup
uses: ./.github/actions/setup

Expand Down Expand Up @@ -42,7 +73,7 @@ jobs:
HIGHLIGHTS: ${{ steps.highlights.outputs.highlights }}

# Update the release PR body
- run: gh pr edit ${{ inputs.releasePr }} --body-file ${{ steps.release_notes.outputs.release_notes_path }}
- run: gh pr edit ${{ github.event_name == 'issue_comment' && github.event.issue.number || inputs.releasePr }} --body-file ${{ steps.release_notes.outputs.release_notes_path }}
shell: bash
env:
GITHUB_TOKEN: ${{ github.token }}