@@ -6,6 +6,35 @@ on: # yamllint disable-line rule:truthy
6
6
types : [created]
7
7
8
8
jobs :
9
+ # Since `issue_comment` event runs on the default branch,
10
+ # we need to get the branch of the pull request
11
+ fetch-branch-name :
12
+ if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
13
+ name : Fetch branch name
14
+ runs-on : ubuntu-latest
15
+ outputs :
16
+ head_ref : ${{ steps.pr_branch.outputs.head_ref }}
17
+ head_sha : ${{ steps.pr_branch.outputs.head_sha }}
18
+ steps :
19
+ - name : Get PR branch
20
+ id : pr_branch
21
+ uses : xt0rted/pull-request-comment-branch@v2
22
+ # Since `issue_comment` event workflow will not appear on the
23
+ # pull request page, we need to set the status of the job
24
+ # in order to attach it to the pull request itself
25
+ set-status-pending :
26
+ if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
27
+ name : Set job status as pending
28
+ runs-on : ubuntu-latest
29
+ needs : [fetch-branch-name]
30
+ steps :
31
+ - name : Set job status as pending
32
+ uses : myrotvorets/set-commit-status-action@master
33
+ with :
34
+ sha : ${{ needs.fetch-branch-name.outputs.head_sha }}
35
+ token : ${{ secrets.GITHUB_TOKEN }}
36
+ status : pending
37
+
9
38
create-runner :
10
39
if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
11
40
name : Create Runner
25
54
setup-runner :
26
55
if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
27
56
name : Setup Runner
28
- needs : create-runner
57
+ needs : [fetch-branch-name, create-runner]
29
58
runs-on : self-hosted
30
59
continue-on-error : true # This is done to release equinix runners irrespective of failure
31
60
outputs :
50
79
51
80
- name : Checkout code
52
81
uses : actions/checkout@v3
82
+ with :
83
+ ref : ${{ needs.fetch-branch-name.outputs.head_ref }}
53
84
54
85
- name : Run playbook
55
86
id : run-playbook
68
99
if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
69
100
name : Cleanup
70
101
runs-on : ubuntu-latest
71
- needs : [setup -runner]
102
+ needs : create -runner
72
103
steps :
73
104
- name : delete runner
74
105
uses : rootfs/metal-delete-action@main
@@ -82,10 +113,24 @@ jobs:
82
113
if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
83
114
name : Mark workflow as failed
84
115
runs-on : ubuntu-latest
85
- needs : [ setup-runner]
116
+ needs : setup-runner
86
117
steps :
87
118
- name : Mark workflow as failed if playbook failed
88
119
if : needs.setup-runner.outputs.playbook-status == 'failure'
89
120
run : |
90
121
echo "Playbook failed, marking workflow as failed"
91
122
exit 1
123
+
124
+ set-final-status :
125
+ if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
126
+ name : Set final status
127
+ runs-on : ubuntu-latest
128
+ needs : fetch-branch-name
129
+ steps :
130
+ - name : Set job status as ${{ job.status }}
131
+ uses : myrotvorets/set-commit-status-action@master
132
+ if : always()
133
+ with :
134
+ sha : ${{ needs.fetch-branch-name.outputs.head_sha }}
135
+ token : ${{ secrets.GITHUB_TOKEN }}
136
+ status : ${{ job.status }}
0 commit comments