Docker build Alpine image #586
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images | |
name: Docker build Alpine image | |
on: | |
release: | |
types: [created] | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
# * is a special character in YAML so you have to quote this string | |
# at 4 am | |
- cron: '0 4 * * *' | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
docker-build-alpine: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
# https://github.com/docker/setup-qemu-action | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
# https://github.com/docker/setup-buildx-action | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to GH packages | |
# https://github.com/docker/login-action | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
# https://github.com/docker/metadata-action | |
uses: docker/metadata-action@v4 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
flavor: | | |
latest=false | |
prefix= | |
suffix=-alpine | |
- name: Build and push Docker image | |
# https://github.com/docker/build-push-action | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: ./DockerfileAlpine | |
platforms: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64/v8 | |
push: ${{ github.event_name == 'release' && github.event.action == 'created' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |