-
Notifications
You must be signed in to change notification settings - Fork 799
102 lines (91 loc) · 3.5 KB
/
build-docker.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
name: Build Docker
on:
push:
branches: [ 'trunk' ]
paths:
- 'tools/docker/Dockerfile'
- 'tools/docker/bin/run.sh'
- 'tools/docker/config/*'
- '.github/versions.sh'
- '.github/workflows/build-docker.yml'
pull_request:
paths:
- 'tools/docker/Dockerfile'
- 'tools/docker/bin/run.sh'
- 'tools/docker/config/*'
- '.github/versions.sh'
- '.github/workflows/build-docker.yml'
concurrency:
group: build-docker-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build and publish Jetpack Dev Environment
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
timeout-minutes: 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh.
steps:
- uses: actions/checkout@v3
- name: Set up qemu
uses: docker/setup-qemu-action@v2
with:
platforms: arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: matticbot
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }}
- name: Log in to GitHub Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Fetch build args
id: buildargs
run: |
source .github/versions.sh
source .github/files/gh-funcs.sh
gh_set_output php-version "$PHP_VERSION"
gh_set_output composer-version "$COMPOSER_VERSION"
gh_set_output node-version "$NODE_VERSION"
gh_set_output pnpm-version "$PNPM_VERSION"
# We're not git-tagging for the env. Just tag all trunk builds as latest.
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then
gh_set_output tags "type=raw,latest"
gh_set_output images $'automattic/jetpack-wordpress-dev\nghcr.io/automattic/jetpack-wordpress-dev'
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
gh_set_output tags "type=ref,event=pr"
gh_set_output images "ghcr.io/automattic/jetpack-wordpress-dev"
else
echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME"
exit 1
fi
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v4
with:
flavor: latest=false
tags: ${{ steps.buildargs.outputs.tags }}
images: ${{ steps.buildargs.outputs.images }}
labels: |
org.opencontainers.image.title=Jetpack Development Environment
org.opencontainers.image.description=Unified environment for developing in the Jetpack Monorepo using Docker containers.
org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: tools/docker
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
PHP_VERSION=${{ steps.buildargs.outputs.php-version }}
COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }}
NODE_VERSION=${{ steps.buildargs.outputs.node-version }}
PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }}