Skip to content

Commit

Permalink
chore(NODE-5768): add comment trigger for release notes (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken authored Nov 30, 2023
1 parent a382485 commit 99cd066
Showing 1 changed file with 32 additions and 1 deletion.
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 }}

0 comments on commit 99cd066

Please sign in to comment.