Skip to content

Commit dc46811

Browse files
joshblackCopilot
andauthored
ci: add status workflow for overriding github-ci checks (#7131)
Co-authored-by: Copilot <[email protected]>
1 parent 01b16db commit dc46811

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

.github/workflows/recommend-integration-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ jobs:
5858
await github.rest.issues.addLabels({...issue, labels: [INTEGRATION_LABEL_NAMES.recommended]})
5959
await github.rest.issues.createComment({
6060
...issue,
61-
body: '<!-- recommend-integration-tests.yml -->\n\n :wave: Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the [integration workflow](https://gh.io/testing_primer_at_dotcom). Thanks!'
61+
body: '<!-- recommend-integration-tests.yml -->\n\n :wave: Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the [integration workflow](https://gh.io/testing_primer_at_dotcom). Or, apply the `integration-tests: skipped manually` label to skip these checks.'
6262
})
6363
} else if (hasPassingLabel) {
6464
// recommend running integration tests again as there are new commits that might change the status
6565
// note: we don't remove 'integration-tests: passing' label because this is only a suggestion/nudge
6666
await github.rest.issues.addLabels({...issue, labels: [INTEGRATION_LABEL_NAMES.recommended]})
6767
await github.rest.issues.createComment({
6868
...issue,
69-
body: '<!-- recommend-integration-tests.yml -->\n\n :wave: Hi, there are new commits since the last successful integration test. We recommend running the [integration workflow](https://gh.io/testing_primer_at_dotcom) once more, unless you are sure the new changes do not affect github/github. Thanks!'
69+
body: '<!-- recommend-integration-tests.yml -->\n\n :wave: Hi, there are new commits since the last successful integration test. If you are GitHub staff, test these changes with github/github-ui using the [integration workflow](https://gh.io/testing_primer_at_dotcom). Or, apply the `integration-tests: skipped manually` label to skip these checks.'
7070
})
7171
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: status-checks
2+
3+
on:
4+
pull_request:
5+
types: [labeled, opened, reopened, synchronize]
6+
7+
permissions:
8+
pull-requests: write
9+
statuses: write
10+
11+
jobs:
12+
github-ui:
13+
runs-on: ubuntu-latest
14+
if: "${{ contains(github.event.pull_request.labels.*.name, 'integration-tests: skipped manually') }}"
15+
steps:
16+
- name: Override status checks
17+
run: |
18+
# Get the timeline event ID for the label being added
19+
EVENT_ID=$(gh api "/repos/primer/react/issues/$PR_NUMBER/timeline" \
20+
--jq '.[] | select(.event == "labeled" and .label.name == "integration-tests: skipped manually") | .id' \
21+
| tail -n 1)
22+
23+
# Construct the HTML URL from the event ID
24+
if [ -n "$EVENT_ID" ]; then
25+
TARGET_URL="${{ github.event.pull_request.html_url }}#event-$EVENT_ID"
26+
else
27+
TARGET_URL="${{ github.event.pull_request.html_url }}"
28+
fi
29+
30+
gh api -X POST "/repos/primer/react/statuses/$SHA" \
31+
-f state='success' \
32+
-f context='github-ui / ci' \
33+
-f description='Skipped' \
34+
-f target_url="$TARGET_URL"
35+
36+
gh api -X POST "/repos/primer/react/statuses/$SHA" \
37+
-f state='success' \
38+
-f context='github-ui / projects' \
39+
-f description='Skipped' \
40+
-f target_url="$TARGET_URL"
41+
env:
42+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
SHA: ${{ github.event.pull_request.head.sha }}
44+
PR_NUMBER: ${{ github.event.pull_request.number }}

0 commit comments

Comments
 (0)