Skip to content

Update build-images.yml #19

Update build-images.yml

Update build-images.yml #19

Workflow file for this run

name: Build Docker Images
permissions:
contents: read
packages: write
on:
push:
branches: [ main ]
paths-ignore:
- "README.md"
- "docker-compose.yml"
- "examples/**"
- ".run/**"
- ".circleci/**"
concurrency:
group: "${{ github.workflow }}-${{ github.ref }}"
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php_version: ['8.3', '8.1', '8.0', '7.4']
variant: ['apache', 'apache-chrome']
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set variables
run: |
if [ "${{ matrix.variant }}" == "apache" ]; then
echo "DOCKER_TAG=${{ matrix.php_version }}" >> $GITHUB_ENV
echo "DOCKER_FILE=Dockerfile" >> $GITHUB_ENV
elif [ "${{ matrix.variant }}" == "apache-chrome" ]; then
echo "DOCKER_TAG=${{ matrix.php_version }}-headless" >> $GITHUB_ENV
echo "DOCKER_FILE=Dockerfile-headless" >> $GITHUB_ENV
else
echo "Invalid variant: ${{ matrix.variant }}"
exit 1
fi
- name: Skip build if file does not exist
run: |
if [ ! -f "./${{ matrix.php_version }}/${{ env.DOCKER_FILE }}" ]; then
exit 0 # Exit successfully if the file does not exist
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Registry
# Only run this step if the secrets are set
if: secrets.DOCKER_HUB_USER && secrets.DOCKER_HUB_TOKEN

Check failure on line 58 in .github/workflows/build-images.yml

View workflow run for this annotation

GitHub Actions / Build Docker Images

Invalid workflow file

The workflow is not valid. .github/workflows/build-images.yml (Line: 58, Col: 13): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.DOCKER_HUB_USER && secrets.DOCKER_HUB_TOKEN
run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u ${{ secrets.DOCKER_HUB_USER }} --password-stdin
- name: Login to GitHub Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Github Short SHA
run: |
echo "GITHUB_SHA_SHORT=$(echo $GITHUB_SHA | cut -c 1-7)" >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./${{ matrix.php_version }}/${{ env.DOCKER_FILE }}
tags:
ghcr.io/${{ github.repository }}:${{ env.DOCKER_TAG }},
ghcr.io/${{ github.repository }}:${{ env.GITHUB_SHA_SHORT }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max