Skip to content

[Sharp-API] Fix workflow #65

[Sharp-API] Fix workflow

[Sharp-API] Fix workflow #65

Workflow file for this run

name: PHP-FPM Docker Build and Push
on:
push:
tags:
- 'php-fpm-[^alpine]*'
jobs:
build-and-push:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: buildjet-4vcpu-ubuntu-2204
platform: linux/amd64
- os: buildjet-4vcpu-ubuntu-2204-arm
platform: linux/arm64
- os: buildjet-4vcpu-ubuntu-2204-arm
platform: linux/arm/v7
outputs:
version: ${{ env.version }}
latest: ${{ env.IS_LATEST }}
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Prepare the Docker tags list and PHP version
id: prep
run: |
FULL_VERSION=$(echo ${{ github.ref }} | sed -e 's,.*/php-fpm-,,')
VERSION=${FULL_VERSION%-latest}
TAGS="${{ secrets.DOCKER_USERNAME }}/php:${VERSION}-fpm"
IS_LATEST=false
if [[ ${{ matrix.platform }} == "linux/amd64" ]]; then
SUFFIX="-amd64"
elif [[ ${{ matrix.platform }} == "linux/arm64" ]]; then
SUFFIX="-arm64"
elif [[ ${{ matrix.platform }} == "linux/arm/v7" ]]; then
SUFFIX="-armv7"
fi
TAGS="${{ secrets.DOCKER_USERNAME }}/php:${VERSION}-fpm${SUFFIX}"
if [[ "$FULL_VERSION" == *"-latest" ]]; then
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/php:latest${SUFFIX}"
IS_LATEST=true
fi
echo "TAGS=$TAGS" >> $GITHUB_ENV
echo "PHP_VERSION=${VERSION%-fpm}" >> $GITHUB_ENV
echo "version=${VERSION%-fpm}" >> $GITHUB_ENV
echo "IS_LATEST=$IS_LATEST" >> $GITHUB_ENV
echo "PHP_VERSION=${VERSION%-fpm}"
echo "Building with tags: $TAGS"
- name: Start multi-arch build and push
uses: docker/build-push-action@v5
with:
context: ./PHP/FPM
file: ./PHP/FPM/Dockerfile
build-args: PHP_VERSION=${{ env.PHP_VERSION }}
push: true
tags: ${{ env.TAGS }}
platforms: ${{ matrix.platform }}
provenance: false
- name: Logout from DockerHub
run: docker logout
manifest:
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Set image prefix
run: echo "IMAGE_PREFIX=${{ secrets.DOCKER_USERNAME }}/php:${{ needs.build-and-push.outputs.version }}-fpm" >> $GITHUB_ENV
- name: Create and push manifest images
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ secrets.DOCKER_USERNAME }}/php:${{ needs.build-and-push.outputs.version }}-fpm
images: ${{ env.IMAGE_PREFIX }}-amd64,${{ env.IMAGE_PREFIX }}-arm64,${{ env.IMAGE_PREFIX }}-armv7
push: true
amend: true
- name: Check outputs for latest
run: echo "Latest ${{ needs.build-and-push.outputs.latest }}"
- name: Set image prefix for latest
if: ${{ needs.build-and-push.outputs.latest == 'true' }}
run: echo "IMAGE_PREFIX=${{ secrets.DOCKER_USERNAME }}/php:latest" >> $GITHUB_ENV
- name: Create and push manifest images for latest
if: ${{ needs.build-and-push.outputs.latest == 'true' }}
uses: Noelware/docker-manifest-action@master
with:
inputs: ${{ env.IMAGE_PREFIX }}
images: ${{ env.IMAGE_PREFIX }}-amd64,${{ env.IMAGE_PREFIX }}-arm64,${{ env.IMAGE_PREFIX }}-armv7
push: true
amend: true
- name: Logout from DockerHub
run: docker logout