Skip to content

Commit

Permalink
ci: Generate tags using docker/metadata-action (#4)
Browse files Browse the repository at this point in the history
Use the `docker/metadata-action` to generate image tags, remove push target from Makefile

Signed-off-by: Christian Kadner <[email protected]>
  • Loading branch information
ckadner authored Mar 1, 2024
1 parent f73d9aa commit f6a224d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 49 deletions.
18 changes: 15 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ jobs:

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

- name: "Log in to quay"
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: quay.io
username: wxpe+github_pusher_bot
Expand All @@ -73,15 +75,25 @@ jobs:
fi
echo "CACHE_TO=$CACHE_TO" >> $GITHUB_ENV
- name: "push tags"
run: echo "PUSH_TAGS=$(scripts/get_image_tags.sh ${QUAY_REPOSITORY} | tr -s '[:blank:]' ',')" >> $GITHUB_ENV
- name: "Generate tags"
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.QUAY_REPOSITORY }}
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha,enable=true,priority=100,prefix=,suffix=,format=short
type=sha,enable=true,priority=100,prefix=${{ github.ref_name }}.,suffix=,format=short
- name: "Build and push"
uses: docker/build-push-action@v5
with:
context: .
target: router-release
tags: ${{ env.PUSH_TAGS }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=registry,ref=${{ env.CACHE_IMAGE }}
cache-to: ${{ env.CACHE_TO }}
push: ${{ github.event_name != 'pull_request' }}
Expand Down
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,3 @@ build-router: ##
--build-arg BUILDKIT_INLINE_CACHE=1 \
--tag "$(server_image_name)" .
docker images

.PHONY: push-router-image
push-router-image: ##
@for tag in $$(./scripts/get_image_tags.sh); do \
image_to_push="$(server_image_repo):$${tag}"; \
docker tag "$(server_image_name)" "$${image_to_push}"; \
echo "Pushing image $${image_to_push}"; \
docker push --quiet "$${image_to_push}"; \
done
37 changes: 0 additions & 37 deletions scripts/get_image_tags.sh

This file was deleted.

0 comments on commit f6a224d

Please sign in to comment.