Skip to content

Commit

Permalink
Add proper tags to docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophB committed Jan 19, 2024
1 parent c2430ca commit 49aa746
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ on:
- seek-1.13
- master-ibisba-demonstrator
- ruby-3
tags:
- "v*.*.*"
pull_request:
branches:
- main

jobs:
build:
Expand All @@ -24,24 +28,32 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- id: generate-image-tag
name: Generate Image Tag
env:
ref_name: "${{ github.ref_name }}"
head_ref: "${{ github.head_ref }}"
run: |
ref_name="${head_ref:-${ref_name/main/latest}}"
echo "::set-output name=imageTag::${ref_name#v}"
uses: actions/checkout@v4
- name: Generate Image Tags
id: generate-image-tags
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable={{is_default_branch}}
type=sha
- name: Login to Container Registry
uses: docker/login-action@v1
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ steps.generate-image-tag.outputs.imageTag }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.generate-image-tags.outputs.tags }}
labels: ${{ steps.generate-image-tags.outputs.labels }}

0 comments on commit 49aa746

Please sign in to comment.