File tree 1 file changed +33
-1
lines changed
1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,46 @@ name: Destroy preview environment
9
9
jobs :
10
10
destroy-preview-environment :
11
11
runs-on : ubuntu-latest
12
- if : github.repository == github.event.pull_request.head.repo.full_name
13
12
steps :
13
+
14
+ id : check-conclusion
15
+ env :
16
+ number : ${{ github.event.number }}
17
+ with :
18
+ github-token : ${{ secrets.GITHUB_TOKEN }}
19
+ result-encoding : string
20
+ script : |
21
+ const { data: pull } = await github.rest.pulls.get({
22
+ ...context.repo,
23
+ pull_number: process.env.number
24
+ });
25
+ const ref = pull.head.sha;
26
+
27
+ const { data: checks } = await github.rest.checks.listForRef({
28
+ ...context.repo,
29
+ ref
30
+ });
31
+
32
+ const check = checks.check_runs.filter(c => c.name === 'deploy-preview-environment');
33
+
34
+ if (check.length === 0) {
35
+ return;
36
+ }
37
+
38
+ const { data: result } = await github.rest.checks.get({
39
+ ...context.repo,
40
+ check_run_id: check[0].id,
41
+ });
42
+
43
+ return result.conclusion;
14
44
- name : Context
45
+ if : steps.check-conclusion.outputs.result == 'success'
15
46
uses : okteto/context@latest
16
47
with :
17
48
token : ${{ secrets.OKTETO_TOKEN }}
18
49
19
50
- name : Destroy preview environment
51
+ if : steps.check-conclusion.outputs.result == 'success'
20
52
uses : okteto/destroy-preview@latest
21
53
with :
22
54
name : pr-${{ github.event.number }}-syuilo
You can’t perform that action at this time.
0 commit comments