.github/workflows/docker.yml
name: docker
on:
release:
types: [ published ]
workflow_dispatch:
inputs:
version:
description: 'Version'
required: true
permissions:
id-token: write
attestations: write
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
- name: Get version
run: |
echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
if [ -n "$VERSION" ]; then
echo "RELEASE_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
fi
env:
VERSION: ${{ inputs.version }}
- name: Build phar
run: php -d phar.readonly=0 bin/build -v"$RELEASE_VERSION"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: deployphp/deployer
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,format=long
type=sha
type=semver,pattern=v{{major}}.{{minor}}.{{patch}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern=v{{major}}
type=ref,event=tag
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: deployphp
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
provenance: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}