Skip to content

Commit

Permalink
Expand Docker image tagging (#919)
Browse files Browse the repository at this point in the history
Co-authored-by: Goostaf <gasplund2@gmail.com>
  • Loading branch information
Oscariremma and GAsplund authored Nov 10, 2024
1 parent 1da4c33 commit 0d1734d
Showing 1 changed file with 23 additions and 5 deletions.
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

0 comments on commit 0d1734d

Please sign in to comment.