Skip to content

Commit 5961df7

Browse files
authored
Automatically close weekly ci issue if weekly ci succeeds (#18016)
# Objective It's not always obvious when the issue created by the weekly CI run is safe to close. ## Solution Automatically close it when a weekly CI run succeeds so it doesn't get forgotten. ## Testing Hope.
1 parent df5e3a7 commit 5961df7

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/weekly.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ env:
1212
CARGO_INCREMENTAL: 0
1313
CARGO_PROFILE_TEST_DEBUG: 0
1414
CARGO_PROFILE_DEV_DEBUG: 0
15+
ISSUE_TITLE: Main branch fails to compile on Rust beta.
1516

1617
# The jobs listed here are intentionally skipped when running on forks, for a number of reasons:
1718
#
@@ -82,6 +83,30 @@ jobs:
8283
# See tools/ci/src/main.rs for the commands this runs
8384
run: cargo run -p ci -- compile
8485

86+
close-any-open-issues:
87+
runs-on: ubuntu-latest
88+
needs: ['test', 'lint', 'check-compiles']
89+
permissions:
90+
issues: write
91+
steps:
92+
- name: Close issues
93+
run: |
94+
previous_issue_number=$(gh issue list \
95+
--search "$ISSUE_TITLE in:title" \
96+
--json number \
97+
--jq '.[0].number')
98+
if [[ -n $previous_issue_number ]]; then
99+
gh issue close $previous_issue_number \
100+
-r completed \
101+
-c $COMMENT
102+
fi
103+
env:
104+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
105+
GH_REPO: ${{ github.repository }}
106+
COMMENT: |
107+
[Last pipeline run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) successfully completed. Closing issue.
108+
109+
85110
open-issue:
86111
name: Warn that weekly CI fails
87112
runs-on: ubuntu-latest
@@ -95,22 +120,21 @@ jobs:
95120
- name: Create issue
96121
run: |
97122
previous_issue_number=$(gh issue list \
98-
--search "$TITLE in:title" \
123+
--search "$ISSUE_TITLE in:title" \
99124
--json number \
100125
--jq '.[0].number')
101126
if [[ -n $previous_issue_number ]]; then
102127
gh issue comment $previous_issue_number \
103128
--body "Weekly pipeline still fails: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
104129
else
105130
gh issue create \
106-
--title "$TITLE" \
131+
--title "$ISSUE_TITLE" \
107132
--label "$LABELS" \
108133
--body "$BODY"
109134
fi
110135
env:
111136
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112137
GH_REPO: ${{ github.repository }}
113-
TITLE: Main branch fails to compile on Rust beta.
114138
LABELS: C-Bug,S-Needs-Triage
115139
BODY: |
116140
## Weekly CI run has failed.

0 commit comments

Comments
 (0)