Skip to content

Commit 3f5838a

Browse files
authored
Merge pull request #180 from davidaparicio/dev/daparicio/docker-support-prefixed-version-tags
build: support prefixed version tags in docker-release workflow
2 parents 3650c7e + 3ba9dff commit 3f5838a

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

.github/workflows/docker-release.yaml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
tags:
66
- '[0-9]+.[0-9]+.[0-9]+'
7+
- 'cloudflare-exporter-[0-9]+.[0-9]+.[0-9]+'
78

89
jobs:
910
build-and-push-docker-image:
@@ -19,6 +20,15 @@ jobs:
1920
- name: Checkout code
2021
uses: actions/checkout@v5
2122

23+
- name: Extract version from tag
24+
id: version
25+
run: |
26+
TAG="${{ github.ref_name }}"
27+
# Strip 'cloudflare-exporter-' prefix if present
28+
VERSION="${TAG#cloudflare-exporter-}"
29+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
30+
echo "Extracted version: $VERSION"
31+
2232
- name: Login to Github Packages
2333
uses: docker/login-action@v3
2434
with:
@@ -39,7 +49,7 @@ jobs:
3949
- name: Build and push
4050
id: publish-image
4151
env:
42-
IMAGE_VERSION: ${{ github.ref_name }}
52+
IMAGE_VERSION: ${{ steps.version.outputs.version }}
4353
KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}"
4454
run: |
4555
ko build . --sbom=none --image-refs ./image-digest --bare --platform linux/arm64,linux/amd64 -t ${IMAGE_VERSION} \
@@ -80,9 +90,20 @@ jobs:
8090
permissions:
8191
packages: read
8292
steps:
93+
# Extract version again since this job runs on a different runner
94+
# and doesn't have access to outputs from the previous job's steps
95+
- name: Extract version from tag
96+
id: version
97+
run: |
98+
TAG="${{ github.ref_name }}"
99+
# Strip 'cloudflare-exporter-' prefix if present
100+
VERSION="${TAG#cloudflare-exporter-}"
101+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
102+
echo "Extracted version: $VERSION"
103+
83104
- name: Copy image to dockerhub
84105
env:
85-
IMAGE_VERSION: ${{ github.ref_name }}
106+
IMAGE_VERSION: ${{ steps.version.outputs.version }}
86107
GHCR_REPO: "ghcr.io/${{ github.repository }}"
87108
GHCR_USERNAME: ${{ github.actor }}
88109
GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)