Build and push Docker images based on Debian #141
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push Docker images based on Debian | |
on: | |
schedule: | |
- cron: '42 5 * * *' | |
push: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
jobs: | |
build-and-push: | |
name: Build and push Docker image based on Debian | |
runs-on: ubuntu-latest | |
permissions: | |
packages: write | |
contents: read | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- composer: "2" | |
debian: "bookworm" | |
php: "8.2" | |
surf: "3" | |
- composer: "2" | |
debian: "bookworm" | |
php: "8.1" | |
surf: "3" | |
- composer: "2" | |
debian: "buster" | |
php: "7.2" | |
surf: "2" | |
- composer: "2" | |
debian: "buster" | |
php: "7.4" | |
surf: "2" | |
- composer: "2" | |
debian: "bullseye" | |
php: "7.4" | |
surf: "2" | |
- composer: "2" | |
debian: "buster" | |
php: "7.4" | |
surf: "3" | |
- composer: "2" | |
debian: "bullseye" | |
php: "7.4" | |
surf: "3" | |
env: | |
IMAGE_NAME: t3easy/surf | |
PLATFORMS: linux/amd64,linux/arm64 | |
steps: | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
if: github.event_name != 'pull_request' | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
if: github.event_name != 'pull_request' | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push images | |
uses: docker/build-push-action@v4 | |
with: | |
push: ${{ github.event_name != 'pull_request' }} | |
platforms: ${{ env.PLATFORMS }} | |
build-args: | | |
COMPOSER_VERSION=${{ matrix.composer }} | |
DEBIAN_VERSION=${{ matrix.debian }} | |
PHP_VERSION=${{ matrix.php }} | |
SURF_VERSION=${{ matrix.surf }} | |
file: Dockerfile-Debian | |
tags: | | |
${{ env.IMAGE_NAME }}:${{ matrix.surf }}-php${{ matrix.php }}-composer${{ matrix.composer }}-${{ matrix.debian }} | |
ghcr.io/${{ env.IMAGE_NAME }}:${{ matrix.surf }}-php${{ matrix.php }}-composer${{ matrix.composer }}-${{ matrix.debian }} | |
cache-from: type=local,src=/tmp/.buildx-cache | |
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |