Skip to content

Commit

Permalink
ci: unify all workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ivivanov authored and Lockwarr committed Sep 17, 2024
1 parent b500853 commit 6b278cd
Show file tree
Hide file tree
Showing 6 changed files with 336 additions and 371 deletions.
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

0 comments on commit 6b278cd

Please sign in to comment.