removed comments #2
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 Docker Image | |
on: | |
push: | |
env: | |
REGISTRY: ghcr.io | |
REGISTRY_IMAGE_NAME: ghcr.io/${{ github.repository }} | |
jobs: | |
build-and-push-amd64: | |
strategy: | |
fail-fast: false | |
matrix: | |
phpversion: | |
- 8.3 | |
- 8.4 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
run: | | |
docker pull ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-amd64 || true | |
docker build \ | |
--cache-from "${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-amd64" \ | |
-f ${{ matrix.phpversion }}/Dockerfile \ | |
-t ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-amd64 . | |
docker push ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-amd64 | |
build-and-push-arm64: | |
strategy: | |
fail-fast: false | |
matrix: | |
phpversion: | |
- 8.3 | |
- 8.4 | |
runs-on: ubuntu-latest-arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and Push Docker Image | |
run: | | |
docker pull ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-arm64 || true | |
docker build \ | |
--cache-from "${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-arm64" \ | |
-f ${{ matrix.phpversion }}/Dockerfile \ | |
-t ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-arm64 . | |
docker push ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-arm64 | |
create-multiarch-manifests: | |
needs: [build-and-push-amd64, build-and-push-arm64] | |
strategy: | |
fail-fast: false | |
matrix: | |
phpversion: | |
- 8.3 | |
- 8.4 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Login to GHCR | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create ${{ matrix.phpversion }} manifest and push | |
run: | | |
docker manifest create \ | |
${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }} \ | |
--amend ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-amd64 \ | |
--amend ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }}-arm64 | |
docker manifest push ${{ env.REGISTRY_IMAGE_NAME }}:${{ matrix.phpversion }} |