Skip to content

docker-publish

docker-publish #26

name: Docker Build and Publish
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
repository_dispatch:
types: [docker-publish]
workflow_dispatch:
inputs:
KITSU_VERSION:
description: "Kitsu Version"
required: true
default: "0.15.50"
LATEST:
description: "Latest"
required: true
default: false
type: boolean
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Set Environment Variable
run: |
# Kitsu version
if [ -n "${{ github.event.client_payload.KITSU_VERSION }}" ]; then
KITSU_VERSION=${{ github.event.client_payload.KITSU_VERSION }}
else
KITSU_VERSION=${{ inputs.KITSU_VERSION }}
fi
echo "KITSU_VERSION=$KITSU_VERSION" >> $GITHUB_ENV
# Latest tag
if [ -z "${{ inputs.LATEST }}" ] || [ "${{ inputs.LATEST }}" == "true" ]; then
LATEST="true"
else
LATEST="false"
fi
echo "LATEST=$LATEST" >> $GITHUB_ENV
- name: Kitsu version and Latest tag
run: |
echo "The KITSU_VERSION is ${{ env.KITSU_VERSION }}"
echo "Latest tag is set to ${{ env.LATEST }}"
- name: Checkout repository
uses: actions/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.PAT }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: latest=${{ env.LATEST }}
tags: type=raw,value=${{ env.KITSU_VERSION }}
- name: Meta version
run: echo "The Meta is ${{ steps.meta.outputs.tags }}"
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: KITSU_VERSION=${{ env.KITSU_VERSION }}
cache-from: type=gha
cache-to: type=gha,mode=max