Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only publish docker image if version is not yet published #926

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ on:
registry:
required: false
type: string
default: 'ghcr.io'
default: "ghcr.io"
image-name:
required: true
type: string
version:
required: true
type: string
default: 'latest'
default: "latest"
dockerfile:
required: true
type: string
Expand All @@ -23,8 +23,8 @@ jobs:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
contents: read
packages: write

steps:
- name: Checkout Repository
Expand All @@ -37,7 +37,19 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Check if version exists
id: check_version
run: |
if docker manifest inspect ${{ inputs.registry }}/${{ inputs.image-name }}:${{ inputs.version }} > /dev/null 2>&1; then
echo "Version ${{ inputs.version }} already exists."
echo "exists=true" >> $GITHUB_ENV
else
echo "Version ${{ inputs.version }} does not exist."
echo "exists=false" >> $GITHUB_ENV
fi

- name: Build and push Docker image
if: env.exists == 'false'
uses: docker/build-push-action@v5
with:
context: .
Expand Down
Loading