-
Notifications
You must be signed in to change notification settings - Fork 0
159 lines (135 loc) · 5.11 KB
/
test-build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: Test Builds
on:
workflow_dispatch:
pull_request:
branches:
- develop
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'
- '8.3'
NODE_VERSION:
- '16'
- '20'
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'
# https://github.com/marketplace/actions/dev-container-build-and-run-action
- name: Pre-build Dev Container Image
uses: devcontainers/[email protected]
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 }}
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 }}
push: never
skipContainerUserIdUpdate: true
- name: Test Copying 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
download:
name: Test Download Images
needs: build
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
PHP_VERSION:
- '8.0'
- '8.3'
NODE_VERSION:
- '16'
- '20'
runs-on: ubuntu-latest
concurrency:
group: ${{ matrix.PHP_VERSION }}-${{ matrix.NODE_VERSION }}-${{ matrix.platform }}
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
- name: List Artifact Downloads
run: ls -R
working-directory: /tmp/${{ env.PACKAGE }}
# 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: Create Manifest List & Image Locally
working-directory: /tmp/${{ env.PACKAGE }}
run: |
docker buildx imagetools create $(jq -cr '.version | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.PACKAGE }}@sha256:%s ' *)
- name: Inspect Manifest List
working-directory: /tmp/${{ env.PACKAGE }}
run: |
docker buildx imagetools inspect ${{ env.PACKAGE }}:php-${{ matrix.PHP_VERSION }}-node-${{ matrix.NODE_VERSION }}