Skip to content

Commit

Permalink
Create versioned docker images and seperate images for dev and master
Browse files Browse the repository at this point in the history
  • Loading branch information
meier-rene committed Oct 22, 2024
1 parent af1c967 commit 6a9817a
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,43 @@ name: Docker Image

on:
push:
branches: [ master ]
branches:
- 'master'
- 'dev'
tags:
- 'v*'

jobs:
docker:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: ipbhalle/metfragweb
tags: |
# tag event
type=ref,event=tag
# set latest tag for main branch and tags
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }}
# set dev tag for dev branch
type=raw,value=dev,enable=${{ github.ref == 'refs/heads/dev'}}
- name: Build and push Docker image
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
push: true
tags: ipbhalle/metfragweb:latest
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=ipbhalle/metfragweb:latest
cache-to: type=inline

0 comments on commit 6a9817a

Please sign in to comment.