feat(CI): Adds GitHub Actions Multi-Platform Dev Container Builds #23
Workflow file for this run
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
name: Test Builds | |
on: | |
workflow_dispatch: | |
pull_request: | |
branches: | |
- develop | |
concurrency: | |
group: '${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
env: | |
PHP_STABLE_VERSION: '8.3' | |
NODE_STABLE_VERSION: '20' | |
REGISTRY: ghcr.io | |
OWNER: ndigitals | |
PACKAGE: wp-dev-container | |
ACTION_VERSION: 1 | |
jobs: | |
build: | |
name: Build Images | |
strategy: | |
fail-fast: false | |
matrix: | |
PHP_VERSION: | |
- '8.0' | |
#- '8.1' | |
#- '8.2' | |
#- '8.3' | |
NODE_VERSION: | |
- '16' | |
#- '18' | |
#- '20' | |
builder: | |
- ubuntu-latest | |
- self-hosted | |
platform: | |
- amd64 | |
- arm64 | |
exclude: | |
- builder: ubuntu-latest | |
platform: arm64 | |
- builder: self-hosted | |
platform: amd64 | |
runs-on: | |
- ${{ matrix.builder }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags | |
# https://github.com/marketplace/actions/docker-setup-buildx | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# https://github.com/marketplace/actions/docker-login | |
- name: Login to GitHub Packages | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
logout: false | |
# https://github.com/marketplace/actions/docker-metadata-action | |
- uses: docker/metadata-action@v5 | |
id: metadata | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }} | |
tags: type=raw,value=php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} | |
flavor: suffix=-${{ matrix.platform }} | |
# https://github.com/marketplace/actions/setup-node-js-environment | |
- name: Setup Node Environment | |
uses: actions/setup-node@v2 | |
with: | |
node-version-file: '.nvmrc' | |
# https://github.com/marketplace/actions/setup-go-environment | |
- name: Setup Go Environment | |
id: setup-go | |
if: matrix.builder == 'skip' | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '1.19.x' | |
cache: false | |
- name: Setup Go Environment Outputs | |
id: go-env | |
if: matrix.builder == 'skip' | |
run: | | |
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT | |
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT | |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_OUTPUT | |
echo "GOROOT=$(go env GOROOT)" >> $GITHUB_OUTPUT | |
echo "GOTOOLDIR=$(go env GOTOOLDIR)" >> $GITHUB_OUTPUT | |
- name: Install skopeo | |
id: install-skopeo | |
if: matrix.builder == 'skip' | |
env: | |
GOCACHE: ${{ steps.go-env.outputs.GOCACHE }} | |
GOMODCACHE: ${{ steps.go-env.outputs.GOMODCACHE }} | |
GOPATH: ${{ steps.go-env.outputs.GOPATH }} | |
GOROOT: ${{ steps.go-env.outputs.GOROOT }} | |
GOTOOLDIR: ${{ steps.go-env.outputs.GOTOOLDIR }} | |
run: | | |
sudo apt-get update | |
sudo apt-get -y install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config | |
rm -rf $GOPATH/src/github.com/containers/skopeo | |
git clone https://github.com/containers/skopeo $GOPATH/src/github.com/containers/skopeo | |
cd $GOPATH/src/github.com/containers/skopeo && DISABLE_DOCS=1 make bin/skopeo | |
sudo make install | |
# https://github.com/marketplace/actions/dev-container-build-and-run-action | |
- name: Pre-build dev container image | |
uses: devcontainers/[email protected] | |
env: | |
PHP_VERSION: ${{ matrix.PHP_VERSION }} | |
NODE_VERSION: ${{ matrix.NODE_VERSION }} | |
with: | |
platform: linux/${{ matrix.platform }} | |
imageName: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }} | |
cacheFrom: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }} | |
imageTag: php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }} | |
push: never | |
skipContainerUserIdUpdate: true | |