-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
336 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: "Ensure docker image" | ||
description: | ||
"Checks if image with specific tag exists in the github container registry. | ||
If it does not exists builds and pushes it." | ||
|
||
inputs: | ||
gh-token: | ||
description: "Github token used to push the image" | ||
required: true | ||
default: "" | ||
|
||
registry: | ||
description: "Github registry" | ||
required: true | ||
default: "ghcr.io" | ||
|
||
repository: | ||
description: "Github repository" | ||
required: true | ||
default: "${{ github.repository }}" | ||
|
||
image-name: | ||
description: "Image name" | ||
required: true | ||
default: "" | ||
|
||
image-tag: | ||
description: "Image tag" | ||
required: true | ||
default: "" | ||
|
||
dockerfile: | ||
description: "Dockerfile path" | ||
required: true | ||
default: "" | ||
|
||
outputs: | ||
tag: | ||
description: "The latest tag which should be used" | ||
value: ${{ steps.tag.outputs.tag }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Check if image exists | ||
shell: bash | ||
run: |- | ||
if docker manifest inspect ${{ inputs.registry }}/${{ inputs.repository }}/${{ inputs.image-name }}:${{ inputs.image-tag }} > /dev/null 2>&1; then | ||
echo "Image exists. Skipping build & push steps." | ||
echo "exists=true" >> $GITHUB_ENV | ||
else | ||
echo "exists=false" >> $GITHUB_ENV | ||
fi | ||
- name: Checkout code | ||
if: env.exists != 'true' | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
if: env.exists != 'true' | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to GitHub Container registry | ||
if: env.exists != 'true' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ inputs.registry }} | ||
username: ${{ github.actor }} | ||
password: ${{ inputs.gh-token}} | ||
|
||
- name: Build and push Docker image | ||
if: env.exists != 'true' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: ${{ inputs.dockerfile }} | ||
push: true | ||
tags: ${{ inputs.registry }}/${{ inputs.repository }}/${{ inputs.image-name }}:${{ inputs.image-tag }} | ||
|
||
- name: Latest tag output | ||
id: tag | ||
shell: bash | ||
run: echo "tag=${{ inputs.image-tag }}" >> $GITHUB_OUTPUT |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.