Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/docker-build-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Docker Build and Publish

on:
push:
# Publish semver tags as releases.
tags: [ 'v*' ] # Push events to matching v*, i.e. v1.0, v1.0.1

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# Base Image Version to use
BASE_IMAGE_VERSION: v2.1.1
# Tag Version which triggered the build
IMAGE_TAG: ${{ github.ref_name }}

jobs:
build:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
cmd:
- arch: arm32v6
platforms: linux/arm/v6
- arch: arm64v8
platforms: linux/arm64/v8
- arch: amd64
platforms: linux/amd64

permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v2

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

#- name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Lower case repository name
run: |
echo "IMAGE_REPO=${REPO,,}" >>${GITHUB_ENV}
env:
REPO: '${{ github.repository }}'

- name: Build and push Docker images
id: build-and-push
run: |
docker buildx build . -f Dockerfile --platform ${{ matrix.cmd.platforms }} --push \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ matrix.cmd.arch }}-${{ env.IMAGE_TAG }} \
-t ${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}:${{ matrix.cmd.arch }}-latest \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that v* tags are added in strongly increasing order? If not, -latest should only be pushed on main branch.

--build-arg FROM_IMAGE=certbot/certbot:${{ matrix.cmd.arch }}-${{ env.BASE_IMAGE_VERSION }}