-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Changes release builds to push platform specific images to repository then use them to build multi-platform manifest list.
- Loading branch information
Showing
3 changed files
with
167 additions
and
90 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 |
---|---|---|
|
@@ -76,7 +76,7 @@ jobs: | |
with: | ||
node-version-file: '.nvmrc' | ||
|
||
# https://github.com/marketplace/actions/dev-container-build-and-run-action | ||
# https://github.com/marketplace/actions/dev-container-build-and-run-acttype=registryion | ||
- name: Pre-build Dev Container Image | ||
uses: devcontainers/[email protected] | ||
env: | ||
|
@@ -88,24 +88,10 @@ jobs: | |
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 }} | ||
push: never | ||
imageTag: php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }} | ||
push: always | ||
skipContainerUserIdUpdate: true | ||
|
||
- name: Prepare Container Image Archive | ||
run: | | ||
rm -f /tmp/php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-oci.tar | ||
mv /tmp/output.tar /tmp/php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-oci.tar | ||
# https://github.com/marketplace/actions/upload-a-build-artifact | ||
- name: Upload Digests | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: ${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }} | ||
path: /tmp/php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-oci.tar | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
upload: | ||
name: Upload Images | ||
needs: build | ||
|
@@ -129,23 +115,9 @@ jobs: | |
runs-on: ubuntu-latest | ||
|
||
concurrency: | ||
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }}-${{ matrix.platform }} | ||
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }} | ||
|
||
steps: | ||
# https://github.com/marketplace/actions/download-a-build-artifact | ||
- name: Download Digests - amd64 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 | ||
path: /tmp/${{ env.PACKAGE }}/amd64/${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-oci.tar | ||
|
||
# https://github.com/marketplace/actions/download-a-build-artifact | ||
- name: Download Digests - arm64 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 | ||
path: /tmp/${{ env.PACKAGE }}/arm64/${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-oci.tar | ||
|
||
# https://github.com/marketplace/actions/docker-setup-buildx | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
@@ -164,14 +136,24 @@ jobs: | |
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 }} | ||
|
||
- name: Inspect Images | ||
working-directory: /tmp/${{ env.PACKAGE }} | ||
run: | | ||
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 | ||
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 | ||
- name: Create Manifest List and Push | ||
run: | | ||
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} \ | ||
--append ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 \ | ||
--append ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 | ||
- name: Inspect Manifest List | ||
working-directory: /tmp/${{ env.PACKAGE }} | ||
run: | | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}@sha256:%s ' *) | ||
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} | ||
release: | ||
name: Publish Release | ||
|
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,150 @@ | ||
name: Test Builds | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
|
||
env: | ||
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' | ||
NODE_VERSION: | ||
- '16' | ||
builder: | ||
- ubuntu-22.04 | ||
- self-hosted | ||
platform: | ||
- amd64 | ||
- arm64 | ||
exclude: | ||
- builder: ubuntu-22.04 | ||
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/setup-node-js-environment | ||
- name: Setup Node Environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: '.nvmrc' | ||
|
||
- name: Install Dev Container CLI | ||
run: npm install -g @devcontainers/cli | ||
|
||
- name: Clean-up & Prepare Temp Space | ||
run: | | ||
rm -f /tmp/*.tar || true | ||
rm -rf /tmp/${{ matrix.platform }} || true | ||
rm -rf /tmp/${{ env.PACKAGE }} || true | ||
mkdir /tmp/${{ env.PACKAGE }} | ||
- name: Pre-build Dev Container Image | ||
env: | ||
# see: https://github.com/devcontainers/ci/issues/191#issuecomment-1603857155 | ||
BUILDX_NO_DEFAULT_ATTESTATIONS: true | ||
PHP_VERSION: ${{ matrix.PHP_VERSION }} | ||
NODE_VERSION: ${{ matrix.NODE_VERSION }} | ||
run: | | ||
devcontainer build --workspace-folder . \ | ||
--image-name ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-${{ matrix.platform }} \ | ||
--platform linux/${{ matrix.platform }} \ | ||
--output type=registry \ | ||
--cache-from ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} \ | ||
--cache-from ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }} | ||
download: | ||
name: Test Download Images | ||
needs: build | ||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
PHP_VERSION: | ||
- '8.0' | ||
NODE_VERSION: | ||
- '16' | ||
|
||
runs-on: ubuntu-latest | ||
|
||
concurrency: | ||
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }} | ||
|
||
steps: | ||
# https://github.com/marketplace/actions/download-a-build-artifact | ||
- name: Download Digests - amd64 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 | ||
path: /tmp/${{ env.PACKAGE }}/ | ||
|
||
# https://github.com/marketplace/actions/download-a-build-artifact | ||
- name: Download Digests - arm64 | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: ${{ env.PACKAGE }}-php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 | ||
path: /tmp/${{ env.PACKAGE }}/ | ||
|
||
# https://github.com/marketplace/actions/docker-setup-buildx | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: List Artifact Downloads | ||
working-directory: /tmp/${{ env.PACKAGE }} | ||
run: ls -R | ||
|
||
# https://github.com/marketplace/actions/docker-metadata-action | ||
- name: Docker Metadata | ||
uses: docker/metadata-action@v5 | ||
id: metadata | ||
with: | ||
tags: type=raw,value=php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} | ||
|
||
- name: Inspect Images | ||
working-directory: /tmp/${{ env.PACKAGE }} | ||
run: | | ||
docker buildx imagetools inspect ./php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 | ||
docker buildx imagetools inspect ./php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 | ||
#- name: Create Manifest List & Image Locally | ||
# working-directory: /tmp/${{ env.PACKAGE }} | ||
# run: | | ||
# docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }} -f php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-amd64 -f php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}-arm64 --dry-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