Skip to content

build and publish docker containers #1

build and publish docker containers

build and publish docker containers #1

name: Build and Publish Containers
on:
push:
branches: [main, unstable]
tags: ['v*']
pull_request:
workflow_dispatch:
schedule:
- cron: '29 13 * * *' # run daily
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Runner Info
run: printenv | sort
- name: Checkout
uses: actions/checkout@v4
- name: Container metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
# Add support for more platforms with QEMU - https://github.com/docker/setup-qemu-action
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
# only log in if we're going to push (ie its a tag)
if: ${{ github.event_name == 'tag' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and Push Images
# build and push if on a tag
if: ${{ github.event_name == 'tag' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache,mode=max
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
- name: Build Images
# build only if not on a tag
if: ${{ github.event_name != 'tag' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64, linux/386, linux/arm64, linux/arm/v6, linux/arm/v7
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildcache
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}