|
| 1 | +name: Build Monorepo Docker |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ 'trunk' ] |
| 5 | + paths: |
| 6 | + - 'tools/docker/Dockerfile.monorepo' |
| 7 | + - 'tools/docker/bin/monorepo' |
| 8 | + - '.github/versions.sh' |
| 9 | + - '.github/workflows/build-docker-monorepo.yml' |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - 'tools/docker/Dockerfile.monorepo' |
| 13 | + - 'tools/docker/bin/monorepo' |
| 14 | + - '.github/versions.sh' |
| 15 | + - '.github/workflows/build-docker-monorepo.yml' |
| 16 | +concurrency: |
| 17 | + group: build-docker-monorepo-${{ github.event_name }}-${{ github.ref }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +jobs: |
| 21 | + build: |
| 22 | + name: Build and publish Jetpack Monorepo Environment |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + packages: write |
| 26 | + contents: read |
| 27 | + timeout-minutes: 60 |
| 28 | + |
| 29 | + steps: |
| 30 | + - uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up qemu |
| 33 | + uses: docker/setup-qemu-action@v3 |
| 34 | + with: |
| 35 | + platforms: arm64 |
| 36 | + |
| 37 | + - name: Set up Docker Buildx |
| 38 | + uses: docker/setup-buildx-action@v3 |
| 39 | + |
| 40 | + - name: Log in to Docker Hub |
| 41 | + uses: docker/login-action@v3 |
| 42 | + with: |
| 43 | + username: matticbot |
| 44 | + password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }} |
| 45 | + |
| 46 | + - name: Log in to GitHub Packages |
| 47 | + uses: docker/login-action@v3 |
| 48 | + with: |
| 49 | + registry: ghcr.io |
| 50 | + username: ${{ github.actor }} |
| 51 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 52 | + |
| 53 | + - name: Fetch build args |
| 54 | + id: buildargs |
| 55 | + run: | |
| 56 | + source .github/versions.sh |
| 57 | + source .github/files/gh-funcs.sh |
| 58 | +
|
| 59 | + gh_set_output php-version "$PHP_VERSION" |
| 60 | + gh_set_output composer-version "$COMPOSER_VERSION" |
| 61 | + gh_set_output node-version "$NODE_VERSION" |
| 62 | + gh_set_output pnpm-version "$PNPM_VERSION" |
| 63 | +
|
| 64 | + if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then |
| 65 | + gh_set_output tags "type=raw,latest" |
| 66 | + gh_set_output images $'automattic/jetpack-monorepo\nghcr.io/automattic/jetpack-monorepo' |
| 67 | + elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then |
| 68 | + gh_set_output tags "type=ref,event=pr" |
| 69 | + gh_set_output images "ghcr.io/automattic/jetpack-monorepo" |
| 70 | + else |
| 71 | + echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME" |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | +
|
| 75 | + - name: Extract Docker metadata |
| 76 | + id: meta |
| 77 | + uses: docker/metadata-action@v5 |
| 78 | + with: |
| 79 | + flavor: latest=false |
| 80 | + tags: ${{ steps.buildargs.outputs.tags }} |
| 81 | + images: ${{ steps.buildargs.outputs.images }} |
| 82 | + labels: | |
| 83 | + org.opencontainers.image.title=Jetpack Monorepo Environment |
| 84 | + org.opencontainers.image.description=Environment for building and testing the Jetpack Monorepo. |
| 85 | + org.opencontainers.image.documentation=${{ github.server_url }}/${{ github.repository }}/blob/trunk/tools/docker/README.md |
| 86 | +
|
| 87 | + - name: Build and push Docker image |
| 88 | + uses: docker/build-push-action@v6 |
| 89 | + with: |
| 90 | + context: tools/docker |
| 91 | + file: tools/docker/Dockerfile.monorepo |
| 92 | + push: true |
| 93 | + tags: ${{ steps.meta.outputs.tags }} |
| 94 | + labels: ${{ steps.meta.outputs.labels }} |
| 95 | + platforms: linux/arm64,linux/amd64 |
| 96 | + build-args: | |
| 97 | + PHP_VERSION=${{ steps.buildargs.outputs.php-version }} |
| 98 | + COMPOSER_VERSION=${{ steps.buildargs.outputs.composer-version }} |
| 99 | + NODE_VERSION=${{ steps.buildargs.outputs.node-version }} |
| 100 | + PNPM_VERSION=${{ steps.buildargs.outputs.pnpm-version }} |
0 commit comments