Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
ci: prevent double image build upon release [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
Lutonite committed Aug 9, 2024
1 parent f33ce38 commit 2061b65
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion .github/workflows/docker-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,32 @@ env:
REGISTRY: ghcr.io

jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Retrieve tags
run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*

- name: Set output variables
id: check
run: |
tag=""
if [[ "${{ github.ref }}" == refs/heads/* ]]; then
tag="$(git tag --points-at HEAD)"
fi
echo "head_tag=${tag}" >> $GITHUB_OUTPUT
outputs:
head_tag: ${{ steps.check.outputs.head_tag }}

build-docker:
name: Build and attest Docker image with JIB
runs-on: ubuntu-latest
needs: [ prepare ]
if: "github.event_name == 'push' && needs.prepare.outputs.head_tag == ''"

permissions:
contents: read
Expand Down Expand Up @@ -67,7 +90,6 @@ jobs:
name: Update staging image tag
runs-on: ubuntu-latest
needs: [ build-docker ]
if: "!startsWith(github.ref, 'refs/tags/v')"

steps:
- name: Checkout
Expand Down

0 comments on commit 2061b65

Please sign in to comment.