Skip to content

fix: script uses wrong directory to build the image #89

fix: script uses wrong directory to build the image

fix: script uses wrong directory to build the image #89

Workflow file for this run

name: Build Docker image
on:
workflow_dispatch:
schedule:
- cron: "5 4 1,15 * *"
push:
branches: [main]
pull_request:
branches: [main]
env:
DOCKERFILE_DIR: php8
jobs:
buildx:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ["8.1", "8.2", "8.3", "8.4", "8.5"]
variant: ["apache-trixie", "apache-bookworm", "fpm-alpine"]
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: hussainweb
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: github.event_name != 'pull_request'
- name: Set Dockerfile directory
if: ${{ matrix.php_version == '8.1' || matrix.php_version == '8.2' || matrix.php_version == '8.3' || matrix.php_version == '8.4' || matrix.php_version == '8.5' }}
run: echo "DOCKERFILE_DIR=php8" >> $GITHUB_ENV
- name: Generate Docker tags
id: tags
run: |
# Base tag with full variant name
TAGS="hussainweb/drupal-base:php${{ matrix.php_version }}-${{ matrix.variant }}"
# For apache-trixie, add the short version tag (e.g., php8.4)
if [ "${{ matrix.variant }}" = "apache-trixie" ]; then
TAGS="${TAGS},hussainweb/drupal-base:php${{ matrix.php_version }}"
fi
# For fpm-alpine, add the short -alpine tag (e.g., php8.4-alpine)
if [ "${{ matrix.variant }}" = "fpm-alpine" ]; then
TAGS="${TAGS},hussainweb/drupal-base:php${{ matrix.php_version }}-alpine"
fi
# For the latest PHP version on apache-trixie, add the latest tag
if [ "${{ matrix.php_version }}" = "8.5" ] && [ "${{ matrix.variant }}" = "apache-trixie" ]; then
TAGS="${TAGS},hussainweb/drupal-base:latest"
fi
echo "tags=${TAGS}" >> $GITHUB_OUTPUT
- name: Build and push Docker image for PHP ${{ matrix.php_version }}
uses: docker/build-push-action@v6
with:
context: ${{ env.DOCKERFILE_DIR }}/${{ matrix.variant }}/
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.tags.outputs.tags }}
build-args: |
PHP_VERSION=${{ matrix.php_version }}-${{ matrix.variant }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max