-
Notifications
You must be signed in to change notification settings - Fork 1.7k
44 lines (39 loc) · 1.67 KB
/
ci-checks.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# This workflow runs on pull requests when they are opened, synchronized, or reopened.
# It performs the following actions:
# 1. Resets the 'ci-passed' label status when a pull request is synchronized or reopened,
# indicating that changes have been pushed and CI needs to rerun.
# 2. Polls every 5 minutes to check if all CI checks have passed.
# 3. Adds the 'ci-passed' label to the pull request if all CI checks pass successfully.
name: Check CI Completion
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
checks: read
pull-requests: write
jobs:
reset_ci_passed_label:
if: github.event_name == 'pull_request' && (github.event.action == 'synchronize' || github.event.action == 'reopened')
runs-on: ubuntu-latest
steps:
- name: Reset ci-passed label status on PR Syncronization
run: |
echo "Resetting 'ci-passed' label as new changes have been pushed."
gh pr edit ${{ github.event.pull_request.number }} --remove-label "ci-passed" --repo $GITHUB_REPOSITORY || echo "Label not present"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
check_ci_status:
runs-on: ubuntu-latest
steps:
- name: Check if all CI checks passed
uses: wechuli/allcheckspassed@0b68b3b7d92e595bcbdea0c860d05605720cf479
with:
delay: '5'
retries: '7'
polling_interval: '5'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Add 'ci-passed' label
if: success()
run: |
gh pr edit ${{ github.event.pull_request.number }} --add-label "ci-passed" --repo $GITHUB_REPOSITORY