Skip to content

Or not

Or not #189

Workflow file for this run

name: Base Image
on:
push:
branches:
- main
- build-arm64-images
paths:
- '.github/workflows/base.yml'
- 'docker/Dockerfile.base'
- 'docker/Dockerfile.base.dockerignore'
- 'docker/Dockerfile.base-dev'
- 'docker/Dockerfile.base-dev.dockerignore'
- 'pyproject.toml'
- 'poetry.lock'
schedule:
- cron: '30 5 */14 * *'
env:
DOCKER_BUILDKIT: 1
BASE_IMAGE: ghcr.io/emfcamp/website-base
DEV_IMAGE: ghcr.io/emfcamp/website-base-dev
TAG: ${{ github.ref_name == 'main' && 'latest' || github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- linux/amd64
- linux/arm64
steps:
- name: Checkout
uses: actions/checkout@v4
- 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
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Populate Base metadata
id: base-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE }}
- name: Build and push Base images
id: build
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.base
platforms: ${{ matrix.platform }}
labels: ${{ steps.base-meta.outputs.labels }}
outputs: type=image,name=${{ env.BASE_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/base-digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/base-digests/${digest#sha256:}"
- name: Upload Base digest
uses: actions/upload-artifact@v3
with:
name: base-digests
path: /tmp/base-digests/*
if-no-files-found: error
retention-days: 1
- name: Populate Dev metadata
id: dev-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DEV_IMAGE }}
- name: Build and push Dev images
id: dev-build
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/Dockerfile.base.dev
platforms: ${{ matrix.platform }}
labels: ${{ steps.dev-meta.outputs.labels }}
outputs: type=image,name=${{ env.DEV_IMAGE }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/dev-digests
digest="${{ steps.dev-build.outputs.digest }}"
touch "/tmp/dev-digests/${digest#sha256:}"
- name: Upload dev digest
uses: actions/upload-artifact@v3
with:
name: dev-digests
path: /tmp/dev-digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs:
- build
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: base-digests
path: /tmp/base-digests
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Base meta
id: base-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.BASE_IMAGE }}
- name: Create base manifest list and push
working-directory: /tmp/base-digests
run: |
docker buildx imagetools create -t ${{ env.BASE_IMAGE }}:${{ env.TAG }} \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${{ steps.base-meta.outputs.json }}") \
$(printf '${{ env.BASE_IMAGE }}@sha256:%s ' *)
- name: Dev meta
id: dev-meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DEV_IMAGE }}
- name: Create dev manifest list and push
working-directory: /tmp/dev-digests
run: |
docker buildx imagetools create -t ${{ env.DEV_IMAGE }}:${{ env.TAG }} \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "${{ steps.dev-meta.outputs.json }}") \
$(printf '${{ env.DEV_IMAGE }}@sha256:%s ' *)