|
| 1 | +# .github/workflows/build-images.yml |
| 2 | +# Builds and pushes the full DocOps Box image matrix to Docker Hub. |
| 3 | +# |
| 4 | +# The build logic lives in scripts/build-matrix.sh; this workflow is a thin |
| 5 | +# harness that sets up the multi-platform build environment and invokes it. |
| 6 | +# |
| 7 | +# Triggers: |
| 8 | +# - Push to `latest` branch (auto-build on merge) |
| 9 | +# - Manual dispatch with optional dry-run flag |
| 10 | +# |
| 11 | +# Required repository secrets: |
| 12 | +# DOCKERHUB_USERNAME — Docker Hub username |
| 13 | +# DOCKERHUB_PASSWORD — Docker Hub access token (not your password) |
| 14 | +# |
| 15 | +# To add a new image to the matrix, edit scripts/build-matrix.sh only. |
| 16 | + |
| 17 | +name: Build and Push Image Matrix |
| 18 | + |
| 19 | +on: |
| 20 | + push: |
| 21 | + branches: |
| 22 | + - latest |
| 23 | + # Only trigger when files that affect the built image actually change. |
| 24 | + # Docs, README, agent notes, etc. do not need a full 12-image rebuild. |
| 25 | + paths: |
| 26 | + - 'Dockerfile' |
| 27 | + - 'entrypoint.sh' |
| 28 | + - 'scripts/build-matrix.sh' |
| 29 | + - 'templates/dockerfile-*.sh' |
| 30 | + - '.github/workflows/build-images.yml' |
| 31 | + - 'Gemfile' |
| 32 | + - 'package.json' |
| 33 | + - 'requirements.txt' |
| 34 | + workflow_dispatch: |
| 35 | + inputs: |
| 36 | + dry_run: |
| 37 | + description: "Dry run — print commands without building or pushing" |
| 38 | + required: false |
| 39 | + default: "false" |
| 40 | + type: boolean |
| 41 | + |
| 42 | +jobs: |
| 43 | + build-matrix: |
| 44 | + name: Build image matrix |
| 45 | + runs-on: ubuntu-latest |
| 46 | + |
| 47 | + steps: |
| 48 | + - name: Checkout |
| 49 | + uses: actions/checkout@v4 |
| 50 | + |
| 51 | + # QEMU adds emulation layers so BuildKit can produce ARM64 images |
| 52 | + # on the AMD64 GitHub-hosted runner. |
| 53 | + - name: Set up QEMU |
| 54 | + uses: docker/setup-qemu-action@v3 |
| 55 | + |
| 56 | + # Buildx is the CLI plugin that drives multi-platform builds via BuildKit. |
| 57 | + - name: Set up Docker Buildx |
| 58 | + uses: docker/setup-buildx-action@v3 |
| 59 | + |
| 60 | + - name: Log in to Docker Hub |
| 61 | + uses: docker/login-action@v3 |
| 62 | + with: |
| 63 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 64 | + password: ${{ secrets.DOCKERHUB_PASSWORD }} |
| 65 | + |
| 66 | + - name: Build and push image matrix |
| 67 | + run: | |
| 68 | + if [[ "${{ inputs.dry_run }}" == "true" ]]; then |
| 69 | + ./scripts/build-matrix.sh --dry-run |
| 70 | + else |
| 71 | + ./scripts/build-matrix.sh --push --gha-cache |
| 72 | + fi |
0 commit comments