Skip to content

Commit

Permalink
build docker just once to save CI
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba committed May 8, 2021
1 parent fd9f8d1 commit bb7257d
Showing 1 changed file with 6 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ env:
jobs:
publish_images:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php-version: ['7.3', '7.4', '8.0']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -42,17 +38,11 @@ jobs:
BRANCH=$(echo "${{ github.ref }}" | sed -e '/refs\/heads\//!d; s,refs/.*/\(.*\),\1,')
if [ "main" == "$BRANCH" ]; then
DOCKER_TAGS="$DOCKER_TAGS php${{ matrix.php-version }}"
if [ "8.0" == "${{ matrix.php-version }}" ]; then
DOCKER_TAGS="$DOCKER_TAGS latest"
fi
DOCKER_TAGS="$DOCKER_TAGS latest"
fi
if [ ! -z "$TAG" ]; then
DOCKER_TAGS="$DOCKER_TAGS $TAG-php${{ matrix.php-version }}"
if [ "8.0" == "${{ matrix.php-version }}" ]; then
DOCKER_TAGS="$DOCKER_TAGS $TAG"
fi
DOCKER_TAGS="$DOCKER_TAGS $TAG"
fi
echo "Image will be tagged with: $DOCKER_TAGS"
Expand All @@ -62,13 +52,13 @@ jobs:
DOCKER_TAG_ARG="$DOCKER_TAG_ARG --tag rector/rector:$ARG"
done
docker buildx create --name builder-php${{ matrix.php-version }} --use
docker buildx create --name builder-php8.0 --use
docker buildx build \
--progress plain \
--cache-from=rector/rector:build-cache-php${{ matrix.php-version }} \
--cache-to=type=registry,ref=rector/rector:build-cache-php${{ matrix.php-version }},mode=max,push=true \
--cache-from=rector/rector:build-cache-php8.0 \
--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=${{ matrix.php-version }} .
--build-arg PHP_VERSION=8 .

0 comments on commit bb7257d

Please sign in to comment.