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