mirror of
https://github.com/rectorphp/rector.git
synced 2025-03-03 06:59:03 +01:00
65 lines
2.2 KiB
YAML
65 lines
2.2 KiB
YAML
name: Build docker images
|
|
on:
|
|
push:
|
|
# Publish `main` as Docker `latest` image.
|
|
branches:
|
|
- main
|
|
|
|
# Publish `v1.2.3` tags as releases.
|
|
tags:
|
|
- '*'
|
|
|
|
env:
|
|
# see https://github.com/composer/composer/issues/9368#issuecomment-718112361
|
|
COMPOSER_ROOT_VERSION: "dev-main"
|
|
|
|
jobs:
|
|
publish_images:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Build images
|
|
run: |
|
|
DOCKER_TAGS=""
|
|
|
|
# Pull tag and branch from github.ref, which is either refs/heads/... or refs/tags/...
|
|
TAG=$(echo "${{ github.ref }}" | sed -e '/refs\/tags\//!d; s,refs/.*/v\?\(.*\),\1,')
|
|
BRANCH=$(echo "${{ github.ref }}" | sed -e '/refs\/heads\//!d; s,refs/.*/\(.*\),\1,')
|
|
|
|
if [ "main" == "$BRANCH" ]; then
|
|
DOCKER_TAGS="$DOCKER_TAGS latest"
|
|
fi
|
|
|
|
if [ ! -z "$TAG" ]; then
|
|
DOCKER_TAGS="$DOCKER_TAGS $TAG"
|
|
fi
|
|
|
|
echo "Image will be tagged with: $DOCKER_TAGS"
|
|
|
|
DOCKER_TAG_ARG=""
|
|
for ARG in $DOCKER_TAGS; do
|
|
DOCKER_TAG_ARG="$DOCKER_TAG_ARG --tag rector/rector:$ARG"
|
|
done
|
|
|
|
docker buildx create --name builder-php8 --use
|
|
docker buildx build \
|
|
--progress plain \
|
|
--cache-from=rector/rector:build-cache-php8 \
|
|
--cache-to=type=registry,ref=rector/rector:build-cache-php8,mode=max,push=true \
|
|
--target rector \
|
|
--push \
|
|
$DOCKER_TAG_ARG \
|
|
--platform linux/amd64,linux/arm64 \
|
|
--build-arg PHP_VERSION=8 .
|