-
Notifications
You must be signed in to change notification settings - Fork 8
48 lines (42 loc) · 1.27 KB
/
close_pr.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
name: Close PR
run-name: "Close Related PAN.DEV PR - (#${{ github.event.number }}) ${{ github.event.pull_request.title }}"
defaults:
run:
shell: bash
permissions:
contents: read
on:
pull_request:
branches: ['main']
types: ['closed']
jobs:
close:
name: Close PAN.DEV preview PR
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/github-script@v6
with:
result-encoding: string
github-token: ${{ secrets.CLSC_PAT }}
script: |
let prs = await github.rest.pulls.list({
owner: "PaloAltoNetworks",
repo: "pan.dev",
state: "open",
})
let prs_list = prs.data
for (let pr of prs_list){
if (pr.head.label == "PaloAltoNetworks:pua_prev_${{ github.event.pull_request.head.ref }}"){
await github.rest.pulls.update({
owner: "PaloAltoNetworks",
repo: "pan.dev",
pull_number: pr.number,
state: "closed",
})
console.log("Closing related PAN.DEV PR: #" + pr.number + " - " + pr.title + " -> " + pr.url)
break
}
}