Skip to content

Commit

Permalink
Create php-test-fpm.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
carry0987 committed Dec 17, 2023
1 parent fac84dd commit db7a832
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/php-test-fpm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: PHP-FPM Docker Build and Push

on:
push:
tags:
- 'php-test-fpm-[^alpine]*'

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
platform: linux/amd64
- os: buildjet-2vcpu-ubuntu-2204-arm
platform: linux/arm64
outputs:
version: ${{ steps.prep.outputs.version }}
steps:
- name: Check out the repo
uses: actions/checkout@v4

- name: Set up QEMU
if: matrix.platform != 'linux/arm64'
uses: docker/setup-qemu-action@v3

- 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"
if [[ "$FULL_VERSION" == *"-latest" ]]; then
TAGS="$TAGS,${{ secrets.DOCKER_USERNAME }}/php:latest"
fi
echo "TAGS=$TAGS" >> $GITHUB_ENV
echo "PHP_VERSION=${VERSION%-fpm}" >> $GITHUB_ENV
echo "version=${VERSION%-fpm}" >> $GITHUB_ENV
echo "PHP_VERSION=${VERSION%-fpm}"
echo "Building with tags: $TAGS"
- name: Build and push Docker image
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 }}

- name: Logout from DockerHub
run: docker logout

manifest:
needs: build
runs-on: ubuntu-latest
steps:
- name: Create and push manifest
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_TOKEN }}
VERSION=${{ needs.build.outputs.version }}
AMD64_TAG="${{ secrets.DOCKER_USERNAME }}/php:${VERSION}-fpm-linux/amd64"
ARM64_TAG="${{ secrets.DOCKER_USERNAME }}/php:${VERSION}-fpm-linux/arm64"
FULL_TAG="${{ secrets.DOCKER_USERNAME }}/php:${VERSION}-fpm"
LATEST_TAG="${{ secrets.DOCKER_USERNAME }}/php:latest-fpm"
docker manifest create $FULL_TAG $AMD64_TAG $ARM64_TAG
docker manifest create $LATEST_TAG $AMD64_TAG $ARM64_TAG
docker manifest annotate $FULL_TAG $AMD64_TAG --arch amd64
docker manifest annotate $FULL_TAG $ARM64_TAG --arch arm64
docker manifest annotate $LATEST_TAG $AMD64_TAG --arch amd64
docker manifest annotate $LATEST_TAG $ARM64_TAG --arch arm64
docker manifest push $FULL_TAG
docker manifest push $LATEST_TAG
docker logout

0 comments on commit db7a832

Please sign in to comment.