Skip to content

build images

build images #82

Workflow file for this run

---
name: "build images"
on:
push:
branches:
- master
workflow_dispatch:
pull_request:
schedule:
- cron: '0 16 * * 0' # Every Sunday at 4PM
env:
DOCKERHUB_ORG: ${{ secrets.DOCKERHUB_ORG }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
build:
name: "Build: ${{ matrix.version }}"
runs-on: ubuntu-20.04
strategy:
fail-fast: false # Don't cancel other jobs if one fails
matrix:
include:
- version: "7.4"
- version: "8.0"
- version: "8.1"
- version: "8.2"
- version: "8.3"
env:
VERSION: ${{ matrix.version }}
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Checkout
uses: actions/checkout@v2
- name: Prepare Tags
id: prep
run: |
DOCKERHUB_IMAGE=${DOCKERHUB_ORG}/${GITHUB_REPOSITORY#*/}
GITHUB_IMAGE=${{ github.repository_owner }}/${GITHUB_REPOSITORY#*/}
VERSION=php${{ matrix.version }}
TAGS="ghcr.io/${GITHUB_IMAGE}:${VERSION}"
# Only push to Dockerhub if secrets are set.
if [ ! -z "${DOCKERHUB_ORG}" ]; then
TAGS="$TAGS,${DOCKERHUB_IMAGE}:${VERSION}"
fi
# Set output parameters.
echo ::set-output name=tags::${TAGS}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
with:
platforms: all
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
if: ${{ github.event_name != 'pull_request' && env.DOCKERHUB_ORG != '' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build
uses: docker/build-push-action@v2
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./src
file: ./src/Dockerfile
build-args: CLI_VERSION=php${{ matrix.version }}
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.prep.outputs.tags }}