-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First cut to moodle-php-apache multiarch builder
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. This requires: 1. Some secrets to be created or used: - DOCKERHUB_USERNAME (to create) - DOCKERHUB_TOKEN (to create) - DOCKERHUB_PASSWORD (to create, grrr, descriptions cannot be updated using PATs, see peter-evans/dockerhub-description#10 - GH_USERNAME (to create) - GITHUB_TOKEN (to use) 2. Autobuilds @ DockerHub to be disabled (this takes exactly on them)
- Loading branch information
Showing
2 changed files
with
86 additions
and
7 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
name: Docker multiarch publish | ||
|
||
on: push | ||
|
||
env: | ||
REPOSITORY: moodle-php-apache | ||
DOCKERHUB_OWNER: moodlehq | ||
GH_OWNER: moodlehq | ||
|
||
jobs: | ||
Build: | ||
# Completely avoid forks to try this workflow. | ||
if: github.repository_owner == 'moodlehq' | ||
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=dev | ||
# 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.GITHUB_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 }} | ||
|
||
# https://github.com/peter-evans/dockerhub-description | ||
# It's horrible that we need to use password here instead of PAT, because | ||
# that's only available via CLI what defeats 2FA. Anyway, we need to | ||
# auto-update de description, so using it (till available via PAT). | ||
# Link: https://github.com/peter-evans/dockerhub-description/issues/10 | ||
# Note that we only update the description with the master branch version. | ||
- name: Set Docker Hub description from README.md | ||
if: github.ref == 'refs/heads/master' | ||
uses: peter-evans/dockerhub-description@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
repository: ${{ env.DOCKERHUB_OWNER }}/${{ env.REPOSITORY }} |
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