Skip to content

Commit

Permalink
WIP!
Browse files Browse the repository at this point in the history
First attempt to switch the automated building of moodle-php-apache
images from DockerHub to GHA. Main reason being that the former doesn't
support multiarch builds (only multiarch storage).

Link: docker/hub-feedback#1874

Experimentally we'll be, also, sending the images to both DockerHub
and GitHub registries in case we need to switch some day.
  • Loading branch information
stronk7 committed Aug 5, 2021
1 parent 04a2b9c commit 65290cc
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/buildx_and_publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Docker multiarch publish

on: push

env:
REPOSITORY: moodle-php-apache
DOCKERHUB_OWNER: stronk7
GH_OWNER: stronk7

jobs:
Build:
# TODO: Remove this restriction (or change it to main repository).
# Avoid forks to try this workflow.
if: github.repository_owner == 'stronk7'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

# Calculate the tags to be pussed to the registries.
- name: Calculate image tag names
id: calculatetags
uses: docker/metadata-action@v3
with:
images: |
${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }}
ghcr.io/${{ env.GH_OWNER }}/${{ env.REPOSITORY }}
flavor: |
latest=false
tags: |
type=raw,value={{branch}}
type=match,pattern=(\d+.\d+),value={{branch}}
# https://github.com/docker/setup-qemu-action#usage
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# https://github.com/marketplace/actions/docker-setup-buildx
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

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

# https://github.com/docker/login-action#github-container-registry
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GH_TOKEN }}

# https://github.com/docker/build-push-action#multi-platform-image
- name: Build and push to Docker Hub and Github registries
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.calculatetags.outputs.tags }}

0 comments on commit 65290cc

Please sign in to comment.