|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - '[0-9]+.[0-9]+.[0-9]+' |
| 7 | + - 'cloudflare-exporter-[0-9]+.[0-9]+.[0-9]+' |
7 | 8 |
|
8 | 9 | jobs: |
9 | 10 | build-and-push-docker-image: |
|
19 | 20 | - name: Checkout code |
20 | 21 | uses: actions/checkout@v5 |
21 | 22 |
|
| 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 | +
|
22 | 32 | - name: Login to Github Packages |
23 | 33 | uses: docker/login-action@v3 |
24 | 34 | with: |
|
39 | 49 | - name: Build and push |
40 | 50 | id: publish-image |
41 | 51 | env: |
42 | | - IMAGE_VERSION: ${{ github.ref_name }} |
| 52 | + IMAGE_VERSION: ${{ steps.version.outputs.version }} |
43 | 53 | KO_DOCKER_REPO: "ghcr.io/${{ github.repository }}" |
44 | 54 | run: | |
45 | 55 | ko build . --sbom=none --image-refs ./image-digest --bare --platform linux/arm64,linux/amd64 -t ${IMAGE_VERSION} \ |
|
80 | 90 | permissions: |
81 | 91 | packages: read |
82 | 92 | 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 | +
|
83 | 104 | - name: Copy image to dockerhub |
84 | 105 | env: |
85 | | - IMAGE_VERSION: ${{ github.ref_name }} |
| 106 | + IMAGE_VERSION: ${{ steps.version.outputs.version }} |
86 | 107 | GHCR_REPO: "ghcr.io/${{ github.repository }}" |
87 | 108 | GHCR_USERNAME: ${{ github.actor }} |
88 | 109 | GHCR_PASSWORD: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments