From 2f382cc9c6e342385c266861f5da64069bf1c793 Mon Sep 17 00:00:00 2001 From: Christoph Beger Date: Mon, 22 Jan 2024 14:55:03 +0100 Subject: [PATCH] Add proper tags to docker images (#25) --- .github/workflows/docker-image.yml | 51 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index d890e9b8b0..58f75c1f91 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -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 }}