Austin Eng | 4315c6a | 2023-11-03 19:33:03 +0000 | [diff] [blame] | 1 | # Sub-workflow to manage commenting on and closing PRs. |
| 2 | name: PR Manager |
| 3 | |
| 4 | on: |
| 5 | workflow_dispatch: |
| 6 | inputs: |
| 7 | pullNumber: |
| 8 | type: number |
| 9 | required: true |
| 10 | state: |
| 11 | type: string |
| 12 | required: true |
| 13 | targetUrl: |
| 14 | type: string |
| 15 | |
| 16 | jobs: |
| 17 | imported: |
| 18 | name: PR Imported |
| 19 | if: inputs.state == 'success' || inputs.state == 'SUCCESS' |
| 20 | runs-on: ubuntu-latest |
| 21 | permissions: |
| 22 | pull-requests: write |
| 23 | steps: |
| 24 | - uses: marocchino/sticky-pull-request-comment@v2 |
| 25 | with: |
| 26 | number: ${{ inputs.pullNumber }} |
| 27 | header: pr_was_imported # key to reuse the same comment |
| 28 | skip_unchanged: true |
| 29 | message: | |
| 30 | 👋 Thanks for your contribution! Your PR has been imported to Gerrit. |
| 31 | Please visit ${{ inputs.targetUrl }} to see it and CC yourself on the change. |
| 32 | After iterating on feedback, please comment on the Gerrit review to notify reviewers. |
| 33 | All reviews are handled within Gerrit, any comments on the GitHub PR may be missed. |
| 34 | You can continue to upload commits to this PR, and they will be automatically imported |
| 35 | into Gerrit. |
| 36 | |
| 37 | merged: |
| 38 | name: PR Merged |
| 39 | if: inputs.state == 'merged' || inputs.state == 'MERGED' |
| 40 | runs-on: ubuntu-latest |
| 41 | permissions: |
| 42 | pull-requests: write |
| 43 | steps: |
| 44 | - uses: marocchino/sticky-pull-request-comment@v2 |
| 45 | with: |
| 46 | number: ${{ inputs.pullNumber }} |
| 47 | header: pr_was_merged # key to reuse the same comment |
| 48 | skip_unchanged: true |
| 49 | message: 🚀 PR was merged in ${{ inputs.targetUrl }}! |
| 50 | |
| 51 | - name: Close PR |
| 52 | uses: actions/github-script@v6 |
| 53 | with: |
| 54 | script: | |
| 55 | await github.rest.pulls.update({ |
| 56 | owner: context.repo.owner, |
| 57 | repo: context.repo.repo, |
| 58 | pull_number: ${{ inputs.pullNumber }}, |
| 59 | state: 'closed', |
| 60 | }); |