Skip to content

Commit f6a224d

Browse files
authored
ci: Generate tags using docker/metadata-action (#4)
Use the `docker/metadata-action` to generate image tags, remove push target from Makefile Signed-off-by: Christian Kadner <[email protected]>
1 parent f73d9aa commit f6a224d

File tree

3 files changed

+15
-49
lines changed

3 files changed

+15
-49
lines changed

.github/workflows/build.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ jobs:
4040

4141
- name: "Log in to Github Container registry"
4242
uses: docker/login-action@v3
43+
if: github.event_name != 'pull_request'
4344
with:
4445
registry: ghcr.io
4546
username: ${{ github.actor }}
4647
password: ${{ secrets.GITHUB_TOKEN }}
4748

4849
- name: "Log in to quay"
4950
uses: docker/login-action@v3
51+
if: github.event_name != 'pull_request'
5052
with:
5153
registry: quay.io
5254
username: wxpe+github_pusher_bot
@@ -73,15 +75,25 @@ jobs:
7375
fi
7476
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
7577
76-
- name: "push tags"
77-
run: echo "PUSH_TAGS=$(scripts/get_image_tags.sh ${QUAY_REPOSITORY} | tr -s '[:blank:]' ',')" >> $GITHUB_ENV
78+
- name: "Generate tags"
79+
id: meta
80+
uses: docker/metadata-action@v5
81+
with:
82+
images: |
83+
${{ env.QUAY_REPOSITORY }}
84+
tags: |
85+
type=ref,event=branch
86+
type=semver,pattern={{version}}
87+
type=semver,pattern={{major}}.{{minor}}
88+
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
89+
type=sha,enable=true,priority=100,prefix=${{ github.ref_name }}.,suffix=,format=short
7890
7991
- name: "Build and push"
8092
uses: docker/build-push-action@v5
8193
with:
8294
context: .
8395
target: router-release
84-
tags: ${{ env.PUSH_TAGS }}
96+
tags: ${{ steps.meta.outputs.tags }}
8597
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
8698
cache-to: ${{ env.CACHE_TO }}
8799
push: ${{ github.event_name != 'pull_request' }}

Makefile

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,3 @@ build-router: ##
2828
--build-arg BUILDKIT_INLINE_CACHE=1 \
2929
--tag "$(server_image_name)" .
3030
docker images
31-
32-
.PHONY: push-router-image
33-
push-router-image: ##
34-
@for tag in $$(./scripts/get_image_tags.sh); do \
35-
image_to_push="$(server_image_repo):$${tag}"; \
36-
docker tag "$(server_image_name)" "$${image_to_push}"; \
37-
echo "Pushing image $${image_to_push}"; \
38-
docker push --quiet "$${image_to_push}"; \
39-
done

scripts/get_image_tags.sh

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)