Skip to content

again...

again... #79

name: Build and Push Docker Image
on:
push:
branches:
- main
jobs:
build-and-push-image:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- directory: ./ubuntu-22.04/
tagging: 8.1-fpm
image: geschke/php-fpm-swrm
- directory: ./ubuntu-22.04-sury-8.2/
tagging: 8.2-fpm-ubuntu22.04-sury
image: geschke/php-fpm-swrm
permissions:
contents: read
packages: write
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Copy composer installation file
run: |
cp ./install-composer.sh ./${{ matrix.directory }}
-
name: Build full tag based on version file
id: generate_tag
run: |
version_file="${{ matrix.directory }}version.txt"
if [[ -f "$version_file" ]]; then
version=$(cat "$version_file")
full_tag="${{ matrix.tagging }}-${version}"
echo "Full tag is: $full_tag"
echo "full_tag=$full_tag" >> "$GITHUB_OUTPUT"
- name: Query existing Docker image tags
id: query_tag
run: |
echo "full tag built in previous step:"
echo "Tag ${{ steps.generate_tag.outputs.full_tag }}"
TAG_EXISTS=$(curl -s "https://hub.docker.com/v2/repositories/${{ matrix.image }}/tags/?page_size=100" | jq -r '.results[].name' | grep -w "${{ matrix.tagging }}" || true)
if [ -n "$TAG_EXISTS" ]; then
echo "Tag ${{ matrix.tagging}} already exists!"
else
echo "Tag ${{ matrix.tagging}} does not exist, proceed with building the image."
fi
#-
# name: Build and push
# uses: docker/build-push-action@v6
# with:
# context: .
# file: ${{ matrix.directory }}/Dockerfile
# push: false
# load: true
# tags: ${{ matrix.tagging }}