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

ci: unify all workflows #160

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
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
83 changes: 83 additions & 0 deletions .github/actions/ensure-docker-image/action.yaml
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
175 changes: 0 additions & 175 deletions .github/workflows/build.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions .github/workflows/lint.yaml

This file was deleted.

Loading