-
-
Notifications
You must be signed in to change notification settings - Fork 12.3k
55 lines (49 loc) · 1.37 KB
/
cancel-pr-tests.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
45
46
47
48
49
50
51
52
53
54
55
name: Cancel PR tests
on:
pull_request_target:
types:
- closed
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
env:
GH_REPO: ${{ github.repository }}
GH_NO_UPDATE_NOTIFIER: 1
GH_PROMPT_DISABLED: 1
PR: ${{ github.event.number }}
jobs:
cancel-tests:
if: >
github.repository_owner == 'Homebrew' &&
!github.event.pull_request.merged
runs-on: ubuntu-latest
container:
image: ghcr.io/homebrew/ubuntu22.04:master
defaults:
run:
shell: bash
permissions:
contents: read
actions: write # for `gh run cancel`
checks: read # for `GitHub.get_workflow_run`
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
with:
core: false
cask: false
test-bot: false
- name: Check CI status
id: check
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
brew check-ci-status --cancel "$PR"
- name: Cancel tests
if: fromJson(steps.check.outputs.cancellable-run-id) != null
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ fromJson(steps.check.outputs.cancellable-run-id) }}
run: |
echo "::notice ::Cancelling tests on closed PR #$PR"
gh run cancel "$RUN_ID"