Skip to content

Commit 29f71be

Browse files
committed
actions: auto close sync failure issue after successful sync runs
1 parent ef5ee21 commit 29f71be

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/sync-upstream.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,23 @@ jobs:
7676
GH_TOKEN: ${{ secrets.SYNC_PAT }}
7777
run: gh workflow run publish-ocv.yml --repo ${{ github.repository }} --ref ocv -f version=${{ steps.version.outputs.release }}
7878

79+
- name: Close failure issue on success
80+
if: success()
81+
env:
82+
GH_TOKEN: ${{ secrets.SYNC_PAT }}
83+
run: |
84+
existing=$(gh issue list --repo ${{ github.repository }} --state open --limit 1000 --json number,title -q '.[] | select(.title == "[actions]: sync upstream failed") | .number' | head -n 1)
85+
if [ -z "$existing" ]; then
86+
exit 0
87+
fi
88+
gh issue close "$existing" --repo ${{ github.repository }} --comment "Closed automatically after a successful sync run: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
89+
7990
- name: Notify on failure
8091
if: failure()
8192
env:
8293
GH_TOKEN: ${{ secrets.SYNC_PAT }}
8394
run: |
84-
existing=$(gh issue list --repo ${{ github.repository }} --search "[actions]: sync upstream failed" --state open --json number -q '.[0].number')
95+
existing=$(gh issue list --repo ${{ github.repository }} --state open --limit 1000 --json number,title -q '.[] | select(.title == "[actions]: sync upstream failed") | .number' | head -n 1)
8596
if [ -z "$existing" ]; then
8697
gh issue create --repo ${{ github.repository }} \
8798
--title "[actions]: sync upstream failed" \

0 commit comments

Comments
 (0)