1111 description : ' Commit SHA to check out. Use PR head SHA to report as PR check.'
1212 required : true
1313 type : string
14+ name :
15+ required : true
16+ type : string
1417
1518jobs :
16- setup :
19+ create_check_run :
1720 runs-on : ubuntu-latest
1821 permissions :
1922 id-token : write
2023 contents : read
24+ outputs :
25+ check_run_id : ${{ steps.create_check.outputs.result }}
26+ steps :
27+ - name : Get GitHub token via dd-octo-sts
28+ uses : DataDog/dd-octo-sts-action@08f2144903ced3254a3dafec2592563409ba2aa0
29+ id : octo-sts
30+ with :
31+ scope : DataDog/integrations-core
32+ policy : self.test-worker-poc
33+
34+ - name : Create Check Run
35+ id : create_check
36+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
37+ with :
38+ github-token : ${{ steps.octo-sts.outputs.token }}
39+ script : |
40+ const response = await github.rest.checks.create({
41+ owner: context.repo.owner,
42+ repo: context.repo.repo,
43+ name: 'Test Worker POC - ${{ inputs.name }}',
44+ head_sha: '${{ inputs.ref }}',
45+ status: 'in_progress',
46+ details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
47+ output: {
48+ title: 'Test Worker POC Running - ${{ inputs.name }}',
49+ summary: 'The test worker POC workflow is currently running for ${{ inputs.name }}.'
50+ }
51+ });
52+ return response.data.id;
53+
54+ setup :
55+ needs : create_check_run
56+ runs-on : ubuntu-latest
2157 outputs :
2258 work_matrix : ${{ steps.set_matrix.outputs.work_matrix }}
23- token : ${{ steps.octo-sts.outputs.token }}
2459
2560 steps :
2661 - name : Check out repository
3368 with :
3469 python-version : ' 3.13'
3570
36- - name : Get GitHub token via dd-octo-sts
37- uses : DataDog/dd-octo-sts-action@08f2144903ced3254a3dafec2592563409ba2aa0
38- id : octo-sts
39- with :
40- scope : DataDog/integrations-core
41- policy : self.test-worker-poc
42-
4371 - name : Parse matrix and set matrix output
4472 id : set_matrix
4573 run : |
@@ -69,43 +97,36 @@ jobs:
6997 with :
7098 ref : ${{ inputs.ref }}
7199
72- - name : Create Check Run
73- id : create_check
74- uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
75- with :
76- github-token : ${{ needs.setup.outputs.token }}
77- script : |
78- const response = await github.rest.checks.create({
79- owner: context.repo.owner,
80- repo: context.repo.repo,
81- name: 'Test Worker POC Test - ${{ matrix.name }}',
82- head_sha: '${{ inputs.ref }}',
83- status: 'in_progress',
84- details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
85- output: {
86- title: 'Test Worker POC Test - ${{ matrix.name }}',
87- summary: 'Test Worker POC Test - ${{ matrix.name }} is currently running.'
88- }
89- });
90- return response.data.id;
91-
92100 - name : Run Generic Task
93- id : run_task
94101 run : |
95102 echo "Running generic logic for job: ${{ matrix.name }}"
96103 echo "Platform: ${{ matrix.platform }}"
97104 echo "Runner: ${{ matrix.runner }}"
98105 echo "Target: ${{ matrix.target }}"
99106 echo "Git SHA: $(git rev-parse HEAD)"
100107
108+ complete_check_run :
109+ runs-on : ubuntu-latest
110+ if : always()
111+ needs : [create_check_run, run_work]
112+ permissions :
113+ id-token : write
114+ contents : read
115+ steps :
116+ - name : Get GitHub token via dd-octo-sts
117+ uses : DataDog/dd-octo-sts-action@08f2144903ced3254a3dafec2592563409ba2aa0
118+ id : octo-sts
119+ with :
120+ scope : DataDog/integrations-core
121+ policy : self.test-worker-poc
122+
101123 - name : Complete Check Run
102- if : always()
103124 uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
104125 with :
105- github-token : ${{ needs.setup .outputs.token }}
126+ github-token : ${{ steps.octo-sts .outputs.token }}
106127 script : |
107- const check_run_id = ${{ steps.create_check .outputs.result }};
108- const conclusion = '${{ steps.run_task.outcome }}'; // Outcome of the specific task
128+ const check_run_id = ${{ needs.create_check_run .outputs.check_run_id }};
129+ const conclusion = '${{ needs.run_work.result }}';
109130
110131 // Map actions conclusion to check run conclusion
111132 // https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#update-a-check-run
@@ -128,7 +149,7 @@ jobs:
128149 conclusion: checkConclusion,
129150 details_url: '${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}',
130151 output: {
131- title: 'Test Worker POC Test - ${{ matrix .name }} Completed ',
132- summary: `The workflow completed with status: ${conclusion}`
152+ title: 'Test Worker POC Completed - ${{ inputs .name }}',
153+ summary: `The workflow completed with status: ${conclusion} for ${{ inputs.name }}. `
133154 }
134155 });
0 commit comments