Repository navigation
publish #1
This file contains hidden or 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: publish | |
| # Publishes giacomeli/makephp images to DockerHub using native runners for | |
| # each architecture (no QEMU), then merges the per-arch tags into multi-arch | |
| # manifests. Manually triggered. | |
| # | |
| # Required repository secrets: | |
| # DOCKERHUB_USERNAME - DockerHub username (giacomeli) | |
| # DOCKERHUB_TOKEN - DockerHub access token with Read & Write scope | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| php_version: | |
| description: PHP version to publish | |
| type: choice | |
| options: ["all", "8.3", "8.4", "8.5"] | |
| default: "all" | |
| env: | |
| IMAGE: giacomeli/makephp | |
| jobs: | |
| build: | |
| name: build ${{ matrix.version }} ${{ matrix.arch.suffix }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| version: ${{ fromJSON(inputs.php_version == 'all' && '["8.3","8.4","8.5"]' || format('["{0}"]', inputs.php_version)) }} | |
| arch: | |
| - { runner: ubuntu-latest, platform: linux/amd64, suffix: amd64 } | |
| - { runner: ubuntu-24.04-arm, platform: linux/arm64, suffix: arm64 } | |
| runs-on: ${{ matrix.arch.runner }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: docker/setup-buildx-action@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push dev (per-arch tag) | |
| run: | | |
| docker buildx build --platform ${{ matrix.arch.platform }} \ | |
| --build-arg PHP_VERSION=${{ matrix.version }} \ | |
| --build-arg PHP_ENABLE_SWOOLE=true \ | |
| --target final \ | |
| --cache-from type=gha,scope=${{ matrix.version }}-${{ matrix.arch.suffix }} \ | |
| --cache-to type=gha,mode=max,scope=${{ matrix.version }}-${{ matrix.arch.suffix }} \ | |
| -t "$IMAGE:${{ matrix.version }}-dev-${{ matrix.arch.suffix }}" \ | |
| --push ./php | |
| - name: Build and push prod (per-arch tag) | |
| run: | | |
| docker buildx build --platform ${{ matrix.arch.platform }} \ | |
| --build-arg PHP_VERSION=${{ matrix.version }} \ | |
| --build-arg PHP_ENABLE_SWOOLE=true \ | |
| --target prod \ | |
| --cache-from type=gha,scope=${{ matrix.version }}-${{ matrix.arch.suffix }} \ | |
| -t "$IMAGE:${{ matrix.version }}-prod-${{ matrix.arch.suffix }}" \ | |
| --push ./php | |
| merge: | |
| name: merge manifests ${{ matrix.version }} | |
| needs: build | |
| strategy: | |
| matrix: | |
| version: ${{ fromJSON(inputs.php_version == 'all' && '["8.3","8.4","8.5"]' || format('["{0}"]', inputs.php_version)) }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Create multi-arch manifests (versioned + dated) | |
| run: | | |
| DATE=$(date +%Y%m%d) | |
| for flavor in dev prod; do | |
| docker buildx imagetools create \ | |
| -t "$IMAGE:${{ matrix.version }}-$flavor" \ | |
| -t "$IMAGE:${{ matrix.version }}-$flavor-$DATE" \ | |
| "$IMAGE:${{ matrix.version }}-$flavor-amd64" \ | |
| "$IMAGE:${{ matrix.version }}-$flavor-arm64" | |
| docker buildx imagetools inspect "$IMAGE:${{ matrix.version }}-$flavor" | |
| done |