Skip to content

Add tag version based on dockerfile #19

Add tag version based on dockerfile

Add tag version based on dockerfile #19

name: Build and Push PHP+Composer Images
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract versions
id: vars
run: |
php=$(grep 'ARG PHP_VERSION' Dockerfile | cut -d= -f2)
composer=$(grep 'ARG COMPOSER_VERSION' Dockerfile | cut -d= -f2)
echo "tag=$php-$composer" >> $GITHUB_OUTPUT
- name: Build and push multi-arch image
uses: docker/build-push-action@v6
with:
context: .
push: true
platforms: linux/amd64,linux/arm64
tags: ghcr.io/${{ github.repository }}:${{ steps.vars.outputs.tag }}