Skip to content

feat(CI): Adds GitHub Actions Multi-Platform Dev Container Builds #9

feat(CI): Adds GitHub Actions Multi-Platform Dev Container Builds

feat(CI): Adds GitHub Actions Multi-Platform Dev Container Builds #9

Workflow file for this run

name: test-build
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'
- name: Install skopeo
if: matrix.builder == 'self-hosted'
run: |
sudo apt-get update
sudo apt-get -y install skopeo
# 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