|
1 | 1 | name: status-checks |
2 | 2 |
|
3 | 3 | on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
4 | 6 | pull_request: |
5 | 7 | types: [labeled, opened, reopened, synchronize] |
6 | 8 | merge_group: |
|
9 | 11 | types: [checks_requested] |
10 | 12 |
|
11 | 13 | permissions: |
| 14 | + issues: write |
12 | 15 | pull-requests: write |
13 | 16 | statuses: write |
14 | 17 |
|
15 | 18 | jobs: |
16 | 19 | github-ui: |
17 | 20 | runs-on: ubuntu-latest |
18 | | - if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' }}" |
| 21 | + if: "${{ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually')) || github.event_name == 'merge_group' || (github.event_name == 'issue_comment' && github.event.issue.pull_request != null) }}" |
19 | 22 | steps: |
20 | 23 | - name: Generate token for primer |
21 | 24 | id: generate_primer_token |
|
24 | 27 | app-id: 902635 |
25 | 28 | owner: 'primer' |
26 | 29 | private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }} |
| 30 | + |
| 31 | + # Support for reporting on required github-ui status checks on pull requests |
27 | 32 | - name: Override status checks for pull request |
28 | 33 | if: "${{ github.event_name == 'pull_request' }}" |
29 | 34 | run: | |
|
54 | 59 | GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} |
55 | 60 | PR_NUMBER: ${{ github.event.pull_request.number }} |
56 | 61 | SHA: ${{ github.event.pull_request.head.sha }} |
| 62 | + |
| 63 | + # Support for reporting on required github-ui status checks in merge queues |
57 | 64 | - name: Override status checks for merge queue |
58 | 65 | if: "${{ github.event_name == 'merge_group' }}" |
59 | 66 | run: | |
|
68 | 75 | -f description='Skipped' |
69 | 76 | env: |
70 | 77 | GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} |
| 78 | + |
| 79 | + # Support for reporting on required github-ui status checks via issue comment, useful for Pull Requests from forks |
| 80 | + - name: Issue comment command |
| 81 | + if: ${{ github.event_name == 'issue_comment' }} |
| 82 | + id: command |
| 83 | + uses: github/command@4002f2aad7964e6d776c2f91bd3f1f87bf6af793 # v2.0.2 |
| 84 | + with: |
| 85 | + command: '.skip-integration-checks' |
| 86 | + allowed_contexts: pull_request |
| 87 | + # Note: this permission step is _critical_ to make sure only maintainers can run the command |
| 88 | + permissions: write |
| 89 | + - name: Override status checks for issue comment |
| 90 | + if: ${{ github.event_name == 'issue_comment' && steps.command.outputs.continue == 'true' }} |
| 91 | + run: | |
| 92 | + SHA=$(gh pr view $NUMBER --json headRefOid --jq '.headRefOid') |
| 93 | + if [ -z "$SHA" ]; then |
| 94 | + echo "No pull request found for issue #$NUMBER, or gh pr view failed." |
| 95 | + exit 1 |
| 96 | + fi |
| 97 | +
|
| 98 | + gh api -X POST "/repos/primer/react/statuses/$SHA" \ |
| 99 | + -f state='success' \ |
| 100 | + -f context='github-ui / ci' \ |
| 101 | + -f description='Manual override' \ |
| 102 | + -f target_url="$COMMENT_URL" |
| 103 | +
|
| 104 | + gh api -X POST "/repos/primer/react/statuses/$SHA" \ |
| 105 | + -f state='success' \ |
| 106 | + -f context='github-ui / projects' \ |
| 107 | + -f description='Manual override' \ |
| 108 | + -f target_url="$COMMENT_URL" |
| 109 | + env: |
| 110 | + COMMENT_URL: ${{ github.event.comment.html_url }} |
| 111 | + GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }} |
| 112 | + NUMBER: ${{ github.event.issue.number }} |
0 commit comments