Skip to content

Commit bcdb340

Browse files
joshblackCopilot
andauthored
ci: add issue comment support for status checks (#7203)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent e338bd6 commit bcdb340

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

.github/workflows/status-checks.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
name: status-checks
22

33
on:
4+
issue_comment:
5+
types: [created]
46
pull_request:
57
types: [labeled, opened, reopened, synchronize]
68
merge_group:
@@ -9,13 +11,14 @@ on:
911
types: [checks_requested]
1012

1113
permissions:
14+
issues: write
1215
pull-requests: write
1316
statuses: write
1417

1518
jobs:
1619
github-ui:
1720
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) }}"
1922
steps:
2023
- name: Generate token for primer
2124
id: generate_primer_token
@@ -24,6 +27,8 @@ jobs:
2427
app-id: 902635
2528
owner: 'primer'
2629
private-key: ${{ secrets.PRIMER_INTEGRATION_APP_PRIVATE_KEY }}
30+
31+
# Support for reporting on required github-ui status checks on pull requests
2732
- name: Override status checks for pull request
2833
if: "${{ github.event_name == 'pull_request' }}"
2934
run: |
@@ -54,6 +59,8 @@ jobs:
5459
GH_TOKEN: ${{ steps.generate_primer_token.outputs.token }}
5560
PR_NUMBER: ${{ github.event.pull_request.number }}
5661
SHA: ${{ github.event.pull_request.head.sha }}
62+
63+
# Support for reporting on required github-ui status checks in merge queues
5764
- name: Override status checks for merge queue
5865
if: "${{ github.event_name == 'merge_group' }}"
5966
run: |
@@ -68,3 +75,38 @@ jobs:
6875
-f description='Skipped'
6976
env:
7077
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

Comments
 (0)