-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (57 loc) · 1.87 KB
/
pr-review-cleanup.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
56
57
58
59
60
61
62
63
64
65
66
name: Cleanup Review Org
on:
pull_request:
types: [closed]
jobs:
check:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
issues: read
outputs:
auth_url: ${{ steps.fetch_auth_url.outputs.result }}
steps:
- name: Fetch Auth Url
id: fetch_auth_url
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const issue_number = context.issue.number;
const comments = await github.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
});
let authUrl = '';
const identifier = 'Review org 🌩️';
for (const comment of comments.data) {
if (comment.body.includes(identifier)) {
const matches = comment.body.match(/auth_url:\s*(.*)/);
if (matches && matches[1]) {
authUrl = matches[1].trim();
console.log("Auth url found");
break;
}
}
}
console.log(authUrl);
return authUrl;
cleanup-on-close:
runs-on: ubuntu-latest
container: ghcr.io/flxbl-io/sfp:latest
needs: check
if: needs.check.outputs.authUrl != '' && needs.check.outputs.authUrl != '""'
steps:
- name: "Authenticate Dev Hub"
run: |
echo "${{ secrets.DEVHUB_SFDX_AUTH_URL }}" > ./authfile
sf org login sfdx-url -f authfile -a devhub
- name: "Authenticate scratch org"
run: |
echo ${{ needs.check.outputs.authUrl }} > ./scratch_authfile
sf org login sfdx-url -f scratch_authfile -a review-org
- name: "Delete org"
run: |
sfp pool:org:delete -u review-org -v devhub