Adding a docker-based dev env #22
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
name: Build Monorepo Docker | |
on: | |
push: | |
branches: [ 'trunk' ] | |
paths: | |
- 'tools/docker/Dockerfile.monorepo' | |
- 'tools/docker/bin/monorepo' | |
- '.github/versions.sh' | |
- '.github/workflows/build-docker-monorepo.yml' | |
pull_request: | |
paths: | |
- 'tools/docker/Dockerfile.monorepo' | |
- 'tools/docker/bin/monorepo' | |
- '.github/versions.sh' | |
- '.github/workflows/build-docker-monorepo.yml' | |
concurrency: | |
group: build-docker-monorepo-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build and publish Jetpack Monorepo Environment | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
timeout-minutes: 60 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: matticbot | |
password: ${{ secrets.DOCKER_HUB_MATTICBOT_TOKEN }} | |
- name: Log in to GitHub Packages | |
uses: docker/login-action@v3 | |
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" | |
if [[ "$GITHUB_EVENT_NAME" == "push" ]]; then | |
gh_set_output tags "type=raw,latest" | |
gh_set_output images $'automattic/jetpack-monorepo\nghcr.io/automattic/jetpack-monorepo' | |
elif [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then | |
gh_set_output tags "type=ref,event=pr" | |
gh_set_output images "ghcr.io/automattic/jetpack-monorepo" | |
else | |
echo "Unknown GITHUB_EVENT_NAME $GITHUB_EVENT_NAME" | |
exit 1 | |
fi | |
- name: Extract Docker metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: latest=false | |
tags: ${{ steps.buildargs.outputs.tags }} | |
images: ${{ steps.buildargs.outputs.images }} | |
labels: | | |
org.opencontainers.image.title=Jetpack Monorepo Environment | |
org.opencontainers.image.description=Environment for building and testing the Jetpack Monorepo. | |
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@v6 | |
with: | |
context: tools/docker | |
file: tools/docker/Dockerfile.monorepo | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
platforms: linux/arm64,linux/amd64 | |
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 }} |