@@ -6,10 +6,12 @@ on: # yamllint disable-line rule:truthy
6
6
types : [created]
7
7
8
8
jobs :
9
- test-mock-acpi :
9
+ initalize-workflow :
10
10
if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
11
- name : Test Mock ACPI
11
+ name : Initialize workflow
12
12
runs-on : ubuntu-latest
13
+ outputs :
14
+ head_sha : ${{ steps.pr_branch.outputs.head_sha }}
13
15
steps :
14
16
# Since `issue_comment` event runs on the default branch,
15
17
# we need to get the branch of the pull request
@@ -27,15 +29,22 @@ jobs:
27
29
token : ${{ secrets.GITHUB_TOKEN }}
28
30
status : pending
29
31
32
+ test-mock-acpi :
33
+ if : github.event.issue.pull_request && github.event.comment.body == '/test-acpi'
34
+ name : Test Mock ACPI
35
+ needs : initalize-workflow
36
+ runs-on : self-hosted
37
+ outputs :
38
+ runner-name : ${{ runner.name }}
39
+ steps :
30
40
- name : Checkout code
31
- if : ${{ success() }}
32
41
uses : actions/checkout@v4
33
42
with :
34
- ref : ${{ steps.pr_branch .outputs.head_sha }}
43
+ ref : ${{ needs.initalize-workflow .outputs.head_sha }}
35
44
36
45
- name : metal-runner-action
46
+ # TODO: use the forked version of metal-runner-action inside sustainable-computing-io organization
37
47
uses : vprashar2929/metal-runner-action@custom-action
38
- # uses: equinix-labs/[email protected]
39
48
with :
40
49
github_token : ${{ secrets.GH_SELF_HOSTED_RUNNER_TOKEN }}
41
50
metal_auth_token : ${{ secrets.EQUINIX_API_TOKEN }}
@@ -65,32 +74,38 @@ jobs:
65
74
- name : Run playbook
66
75
id : run-playbook
67
76
if : ${{ success() }}
68
- continue-on-error : true # This is done to release equinix runners irrespective of failure
69
77
run : |
70
78
echo "Setting up the infra"
71
79
cd ${GITHUB_WORKSPACE}/ansible
72
80
ansible-playbook -vv -i inventory.yaml setup.yaml
73
81
echo "Launching Mock ACPI compose and running validator"
74
82
ansible-playbook -vv -i inventory.yaml mock_acpi_playbook.yaml -e "pr_number=${{ github.event.issue.number }}"
75
83
84
+ cleanup :
85
+ if : ${{ always() }}
86
+ name : Cleanup
87
+ needs : [initalize-workflow, test-mock-acpi]
88
+ runs-on : ubuntu-latest
89
+ steps :
76
90
- name : delete runner
91
+ if : ${{ always() }}
77
92
uses : rootfs/metal-delete-action@main
78
93
with :
79
94
authToken : ${{ secrets.EQUINIX_API_TOKEN }}
80
95
projectID : ${{ secrets.EQUINIX_PROJECT_ID }}
81
- runnerName : ${{ runner. name }}
96
+ runnerName : ${{ needs.test-mock-acpi.outputs.runner- name }}
82
97
83
98
# Marking the workflow as failed if the playbook fails
84
99
- name : Mark workflow as failed if playbook failed
85
- if : ${{ steps.run-playbook.outcome == 'failure' }}
100
+ if : ${{ needs.test-mock-acpi.result == 'failure' }}
86
101
run : |
87
102
echo "Playbook failed, marking workflow as failed"
88
103
exit 1
89
104
90
105
- name : Set job status as ${{ job.status }}
91
106
uses : myrotvorets/set-commit-status-action@master
92
- if : always()
107
+ if : ${{ always() }}
93
108
with :
94
- sha : ${{ steps.pr_branch .outputs.head_sha }}
109
+ sha : ${{ needs.initalize-workflow .outputs.head_sha }}
95
110
token : ${{ secrets.GITHUB_TOKEN }}
96
111
status : ${{ job.status }}
0 commit comments