Skip to content

Commit 9f055bc

Browse files
committed
[Devcontainer]: Sanitize dynamic Docker image tag in workflow
1 parent 457f4a8 commit 9f055bc

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/devcontainer.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ concurrency:
1616
permissions:
1717
contents: read
1818

19-
env:
20-
image_tag: devcontainer:${{ github.head_ref || github.run_id }}
21-
2219
jobs:
2320
build:
2421
name: Build
@@ -43,11 +40,21 @@ jobs:
4340
dockerfile: .devcontainer/ubuntu-24.04/Dockerfile
4441

4542
- name: Set up Docker Buildx
46-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
43+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
44+
45+
- name: Prepare image tag
46+
shell: bash
47+
run: |
48+
RAW_TAG="${GITHUB_HEAD_REF:-$GITHUB_RUN_ID}"
49+
SAFE_TAG=$(echo "$RAW_TAG" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
50+
echo "image_tag=devcontainer:${SAFE_TAG}" >> "$GITHUB_ENV"
4751
4852
- name: Build Docker image
4953
run: |
50-
docker buildx build .devcontainer/ubuntu-24.04/ --tag "${{ env.image_tag }}" --label "runnumber=${{ github.run_id }}" --load
54+
docker buildx build .devcontainer/ubuntu-24.04/ \
55+
--tag "${{ env.image_tag }}" \
56+
--label "runnumber=${{ github.run_id }}" \
57+
--load
5158
5259
- uses: addnab/docker-run-action@4f65fabd2431ebc8d299f8e5a018d79a769ae185 # v3
5360
env:

0 commit comments

Comments
 (0)