diff --git a/.github/workflows/build-docker.yml b/.github/workflows/build-docker.yml index d97f5f05ede42..d6f7b3e46b35b 100644 --- a/.github/workflows/build-docker.yml +++ b/.github/workflows/build-docker.yml @@ -8,6 +8,13 @@ on: - '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 @@ -19,11 +26,19 @@ jobs: permissions: packages: write contents: read - timeout-minutes: 20 # 2021-10-14: Test run took 5 minutes, but there's lots of downloading involved. + timeout-minutes: 60 # 2021-10-26: Build for arm64 is S-L-O-W. Sigh. steps: - uses: actions/checkout@v2 + - name: Set up qemu + uses: docker/setup-qemu-action@v1 + with: + platforms: arm64 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Log in to Docker Hub uses: docker/login-action@v1 with: @@ -46,16 +61,25 @@ jobs: echo "::set-output name=node-version::$NODE_VERSION" echo "::set-output name=pnpm-version::$PNPM_VERSION" + # We're not git-tagging for the env. Just tag all master builds as latest. + if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then + echo "::set-output name=tags::type=raw,latest" + echo "::set-output name=images::automattic/jetpack-wordpress-dev%0Aghcr.io/automattic/jetpack-wordpress-dev" + elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then + echo "::set-output name=tags::type=ref,event=pr" + echo "::set-output name=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@v3 with: - # We're not git-tagging for the env. Just tag all builds as latest. - tags: | - type=raw,latest - images: | - automattic/jetpack-wordpress-dev - ghcr.io/automattic/jetpack-wordpress-dev + 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. @@ -65,6 +89,7 @@ jobs: uses: docker/build-push-action@v2 with: context: tools/docker + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }}