Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand Docker image tagging #919

Merged
merged 7 commits into from
Nov 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .github/workflows/build-and-publish-image.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
name: Build Docker Image

on:
push:
branches: [main]
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+*
pull_request:
branches: [main]

jobs:
build:
Expand Down Expand Up @@ -31,11 +35,25 @@ jobs:
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository_owner }}/gamma
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=edge
type=ref,event=pr

- name: Build Docker image
run: ./gradlew bootBuildImage

- name: Docker Tag and Build
- name: Push docker image
run: |
version=${GITHUB_REF#refs/tags/}
docker tag app:latest ghcr.io/${{ github.repository_owner }}/gamma:${version}
docker push ghcr.io/${{ github.repository_owner }}/gamma:${version}
for tag in $(jq -r '.tags | join(" ")' <<< $DOCKER_METADATA_OUTPUT_JSON ); do
docker image tag app:latest $tag
done
docker image push --all-tags ghcr.io/${{ github.repository_owner }}/gamma