Skip to content

Commit c9955c9

Browse files
committed
ci: Enable slashes in ref name as found in PRs
1 parent 5dd3f4c commit c9955c9

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,20 @@ jobs:
1818
if: >
1919
github.event_name != 'pull_request' ||
2020
github.event.pull_request.head.repo.full_name != github.repository
21+
# Export Docker image name used by dependent jobs
22+
outputs:
23+
image_name: ${{ steps.image_name.outputs.image_name }}
2124
steps:
25+
- name: Define Docker image name
26+
id: image_name
27+
# To satisfy Docker tag naming requirements, we replace all slashes
28+
# in the ref name with dashes.
29+
run: |
30+
SANITIZED_REF_NAME="${GITHUB_REF_NAME//\//-}"
31+
echo "Sanitized GITHUB_REF_NAME: $SANITIZED_REF_NAME"
32+
IMAGE_NAME="ghcr.io/${GITHUB_REPOSITORY}:${SANITIZED_REF_NAME}"
33+
echo "Image name: $IMAGE_NAME"
34+
echo "image_name=$IMAGE_NAME" >> $GITHUB_OUTPUT
2235
- name: Free Disk Space (Ubuntu)
2336
uses: jlumbroso/free-disk-space@main
2437
with:
@@ -39,7 +52,7 @@ jobs:
3952
cache-to: type=gha,mode=max`
4053
file: util/container/Dockerfile
4154
push: true
42-
tags: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }}
55+
tags: ${{ steps.image_name.outputs.image_name }}
4356

4457
########
4558
# Docs #
@@ -53,7 +66,7 @@ jobs:
5366
github.event_name != 'pull_request' ||
5467
github.event.pull_request.head.repo.full_name != github.repository
5568
container:
56-
image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }}
69+
image: ${{ needs.build-docker.outputs.image_name }}
5770
steps:
5871
- uses: actions/checkout@v2
5972
- name: Build docs
@@ -93,7 +106,7 @@ jobs:
93106
github.event_name != 'pull_request' ||
94107
github.event.pull_request.head.repo.full_name != github.repository
95108
container:
96-
image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }}
109+
image: ${{ needs.build-docker.outputs.image_name }}
97110
steps:
98111
- uses: actions/checkout@v2
99112
- name: Run pytest
@@ -111,7 +124,7 @@ jobs:
111124
github.event_name != 'pull_request' ||
112125
github.event.pull_request.head.repo.full_name != github.repository
113126
container:
114-
image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }}
127+
image: ${{ needs.build-docker.outputs.image_name }}
115128
steps:
116129
- uses: actions/checkout@v2
117130
with:
@@ -161,7 +174,7 @@ jobs:
161174
github.event_name != 'pull_request' ||
162175
github.event.pull_request.head.repo.full_name != github.repository
163176
container:
164-
image: ghcr.io/${{ github.repository_owner }}/snitch_cluster:${{ github.ref_name }}
177+
image: ${{ needs.build-docker.outputs.image_name }}
165178
steps:
166179
- uses: actions/checkout@v4
167180
with:

0 commit comments

Comments
 (0)