Skip to content

Commit e048827

Browse files
committed
use correct path
1 parent 3bdce19 commit e048827

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Get called workflow ref
2+
3+
description: >
4+
A workaround to the issue: https://github.com/actions/toolkit/issues/1264.
5+
6+
This is needed for the reusable workflow to be able to access its own version (commit hash)
7+
that is being called by the caller workflow. This allows for using a proper ref of composite actions
8+
inside the reusable workflow.
9+
inputs:
10+
GH_TOKEN_ADMIN:
11+
required: true
12+
description: 'GitHub token with admin permissions to access workflow run details.'
13+
14+
outputs:
15+
caller-ref:
16+
description: 'The reference (commit hash or branch) of the called workflow'
17+
value: ${{ steps.workflows-ref.outputs.caller-ref }}
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Get workflow reference
23+
id: workflows-ref
24+
shell: bash
25+
run: |
26+
ref=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ inputs.GH_TOKEN_ADMIN }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }} | jq -r '.referenced_workflows[0] | .ref')
27+
echo "caller-ref=$ref" >> $GITHUB_OUTPUT

.github/workflows/quality-checks.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,16 @@ on:
3939
required: false
4040
default: "dev_container_build"
4141
jobs:
42+
get-called-ref:
43+
name: Get called ref
44+
runs-on: ubuntu-latest
45+
outputs:
46+
ref: ${{ steps.get_called_ref.outputs.caller-ref }}
47+
steps:
48+
- id: get_called_ref
49+
uses: NHSDigital/eps-common-workflows/.github/actions/get_called_ref@dev_container_build
50+
with:
51+
GH_TOKEN_ADMIN: ${{ secrets.GITHUB_TOKEN }}
4252
quality_checks:
4353
runs-on: ubuntu-22.04
4454
steps:
@@ -421,6 +431,7 @@ jobs:
421431
path: cfn_guard_output
422432

423433
build_dev_container_x64:
434+
needs: [get-called-ref]
424435
permissions:
425436
id-token: write
426437
runs-on: ubuntu-22.04
@@ -434,7 +445,7 @@ jobs:
434445
env:
435446
SCRIPT_TAG: ${{ inputs.check_ecr_image_scan_results_script_tag }}
436447
run: |
437-
curl -L "https://raw.githubusercontent.com/NHSDigital/eps-workflow-quality-checks/refs/heads/${SCRIPT_TAG}/.github/scripts/check_ecr_image_scan_results.sh" -o check_ecr_image_scan_results.sh
448+
curl -L "https://raw.githubusercontent.com/NHSDigital/eps-common-workflows/${{ needs.get-called-ref.outputs.ref }}/.github/scripts/check_ecr_image_scan_results.sh" -o check_ecr_image_scan_results.sh
438449
chmod +x check_ecr_image_scan_results.sh
439450
- name: Build dev container
440451
run: |
@@ -477,6 +488,7 @@ jobs:
477488
./check_ecr_image_scan_results.sh
478489
479490
build_dev_container_arm64:
491+
needs: [get-called-ref]
480492
permissions:
481493
id-token: write
482494
runs-on: ubuntu-22.04-arm
@@ -490,7 +502,7 @@ jobs:
490502
env:
491503
SCRIPT_TAG: ${{ inputs.check_ecr_image_scan_results_script_tag }}
492504
run: |
493-
curl -L "https://raw.githubusercontent.com/NHSDigital/eps-common-workflows/refs/heads/${SCRIPT_TAG}/.github/scripts/check_ecr_image_scan_results.sh" -o check_ecr_image_scan_results.sh
505+
curl -L "https://raw.githubusercontent.com/NHSDigital/eps-common-workflows/${{ needs.get-called-ref.outputs.ref }}/.github/scripts/check_ecr_image_scan_results.sh" -o check_ecr_image_scan_results.sh
494506
chmod +x check_ecr_image_scan_results.sh
495507
496508
- name: Build dev container

0 commit comments

Comments
 (0)