Skip to content

Create and publish a Docker image #1

Create and publish a Docker image

Create and publish a Docker image #1

# see:
# - https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
# - https://github.com/docker/build-push-action/tree/v5.0.0
name: Create and publish a Docker image
on: workflow_dispatch
env:
REGISTRY: ghcr.io
REPOSITORY_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: self-hosted
timeout-minutes: 720
permissions:
contents: read
packages: write
strategy:
matrix:
mysql_version:
- 8.0.28
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set image name
run: |
echo "IMAGE_NAME=`echo ${REPOSITORY_NAME} | tr '[A-Z]' '[a-z]'`" >>${GITHUB_ENV}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
push: true
build-args: MYSQL_VERSION=${{ matrix.mysql_version }}
platforms: linux/amd64,linux/arm64
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.mysql_version }}-${{ github.sha }}
labels: ${{ steps.meta.outputs.labels }}