name: php-fpm-build on: push: branches: [main] paths: - "php-fpm/**" - "shared/php-fpm/**" - ".github/workflows/php-fpm.yml" pull_request: branches: [main] paths: - "php-fpm/**" - "shared/php-fpm/**" - ".github/workflows/php-fpm.yml" workflow_dispatch: inputs: lane: description: 'Lane to build (e.g. 7.4). Use "all" to build all lanes. Leave blank to build based on changes.' required: false default: "" jobs: build: runs-on: ubuntu-latest strategy: fail-fast: false matrix: lane: ["7.4"] steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Check for file changes id: changes uses: tj-actions/changed-files@v44 with: files: | .github/workflows/php-fpm.yml shared/php-fpm/** php-fpm/${{ matrix.lane }}/** - name: Set build flag id: build-flag run: | if [[ "${{ steps.changes.outputs.any_changed }}" == 'true' || "${{ github.event.inputs.lane }}" == 'all' || "${{ github.event.inputs.lane }}" == "${{ matrix.lane }}" ]]; then echo "should_build=true" else echo "should_build=false" fi >> $GITHUB_OUTPUT shell: bash - name: Set up Docker Buildx if: steps.build-flag.outputs.should_build == 'true' uses: docker/setup-buildx-action@v3 - name: Log in to the Container Registry if: steps.build-flag.outputs.should_build == 'true' uses: docker/login-action@v3 with: registry: gitea.auvem.com username: ${{ vars.REGISTRY_USER || github.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta if: steps.build-flag.outputs.should_build == 'true' uses: docker/metadata-action@v5 with: images: gitea.auvem.com/auvem/wordpress-docker/php-fpm tags: | type=raw,value=${{ matrix.lane }}-latest type=raw,value=${{ matrix.lane }}-${{ github.sha }} - name: Build and push Docker image if: steps.build-flag.outputs.should_build == 'true' uses: docker/build-push-action@v6 with: context: . file: ./php-fpm/${{ matrix.lane }}/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 - name: Report build status if: steps.build-flag.outputs.should_build == 'false' run: echo "Skipping build for ${{ matrix.lane }}. No relevant changes detected."