Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Workflow file for this run

name: Publish Docker 🐳 images 📦 to GitHub Container Registry
on:
release:
types: [published]
jobs:
build-release-and-publish-to-ghcr:
if: github.event_name == 'release'
# Explicitly grant the `secrets.GITHUB_TOKEN` permissions.
permissions:
# Grant the ability to write to GitHub Packages (push Docker images to
# GitHub Container Registry).
packages: write
name: Build and publish Release Docker 🐳 images 📦 to GitHub Container Registry
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Get actual patch version
id: actual_patch_version
run: echo ::set-output name=ACTUAL_PATCH_VERSION::$(echo $GITHUB_REF | cut -d / -f 3 )
- name: Get actual minor version
id: actual_minor_version
run: echo ::set-output name=ACTUAL_MINOR_VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d "." -f 1,2)
- name: Get actual major version
id: actual_major_version
run: echo ::set-output name=ACTUAL_MAJOR_VERSION::$(echo $GITHUB_REF | cut -d / -f 3 | cut -d "." -f 1)
- name: Docker compliant registry for image pushes
id: registry
run: echo "REGISTRY=$(echo 'ghcr.io/${{github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: 'arm64'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
# This is the user that triggered the Workflow. In this case, it will
# either be the user whom created the Release or manually triggered
# the workflow_dispatch.
username: ${{ github.actor }}
# `secrets.GITHUB_TOKEN` is a secret that's automatically generated by
# GitHub Actions at the start of a workflow run to identify the job.
# This is used to authenticate against GitHub Container Registry.
# See https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
# for more detailed information.
password: ${{ secrets.GH_TOKEN }}
- name: Build and push alpine based image
uses: docker/build-push-action@v4
with:
file: Dockerfile
context: .
push: true # push the image to ghcr
tags: |
${{ env.REGISTRY }}:latest
${{ env.REGISTRY }}:${{ steps.actual_patch_version.outputs.ACTUAL_PATCH_VERSION }},
${{ env.REGISTRY }}:${{ steps.actual_minor_version.outputs.ACTUAL_MINOR_VERSION }}
${{ env.REGISTRY }}:${{ steps.actual_major_version.outputs.ACTUAL_MAJOR_VERSION }}
${{ env.REGISTRY }}:${{github.sha}}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max