Skip to content

Commit

Permalink
Add proper tags to docker images (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristophB authored Jan 22, 2024
1 parent c2430ca commit 2f382cc
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,46 @@
name: Build Docker Image

on:
workflow_run:
workflows: [ "tests" ]
branches: [ main ]
types: [ "completed" ]
pull_request:
branches:
- main
push:
branches:
- main
- workflow
- workflowhub
- seek-1.11
- seek-1.12
- seek-1.13
- master-ibisba-demonstrator
- ruby-3
pull_request:
release:
types:
- published
workflow_dispatch:

jobs:
build:
name: "Build Image"
if: ${{ github.event.workflow_run.conclusion == 'success' }}
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=tag
type=ref,event=pr
type=sha
- name: Login to Container Registry
uses: docker/login-action@v1
if: contains(fromJSON('["release", "workflow_dispatch"]'), github.event_name)
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: ${{ contains(fromJSON('["release", "workflow_dispatch"]'), github.event_name) }}
tags: ${{ steps.generate-image-tags.outputs.tags }}
labels: ${{ steps.generate-image-tags.outputs.labels }}

0 comments on commit 2f382cc

Please sign in to comment.