mirror of
https://github.com/devilbox/docker-php-fpm.git
synced 2026-01-09 17:41:14 +00:00
243 lines
8.0 KiB
YAML
243 lines
8.0 KiB
YAML
name: Deploy multi-arch images
|
|
|
|
on:
|
|
workflow_call:
|
|
###
|
|
### Variables
|
|
###
|
|
inputs:
|
|
enabled:
|
|
description: 'Determines wheather this workflow is enabled at all (will run or skip).'
|
|
required: true
|
|
type: boolean
|
|
can_deploy:
|
|
description: 'Determines wheather this workflow will also deploy (login and push).'
|
|
required: true
|
|
type: boolean
|
|
build_matrix:
|
|
description: 'The build matrix'
|
|
required: true
|
|
type: string
|
|
has_refs:
|
|
description: 'The ref build matrix as JSON string (list of git refs to build/deploy).'
|
|
required: true
|
|
type: string
|
|
artifact_prefix:
|
|
description: 'Unique artifact name prefix (to avoid overriding existing artifcats during parallel runs).'
|
|
required: true
|
|
type: string
|
|
###
|
|
### Secrets
|
|
###
|
|
secrets:
|
|
dockerhub_username:
|
|
description: 'The username for Dockerhub.'
|
|
required: false
|
|
dockerhub_password:
|
|
description: 'The password for Dockerhub.'
|
|
required: false
|
|
|
|
jobs:
|
|
deploy:
|
|
name: ${{ matrix.name }}-${{ matrix.version }} (${{ matrix.arch }}) ${{ matrix.refs }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include: ${{ fromJson(inputs.build_matrix) }}
|
|
if: inputs.enabled
|
|
steps:
|
|
|
|
# ------------------------------------------------------------
|
|
# Setup repository
|
|
# ------------------------------------------------------------
|
|
- name: "[SETUP] Checkout repository (current)"
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
if: inputs.has_refs == 0
|
|
|
|
- name: "[SETUP] Checkout repository (ref: ${{ matrix.refs }})"
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
ref: ${{ matrix.refs }}
|
|
if: inputs.has_refs != 0
|
|
|
|
- name: "[SETUP] Setup QEMU environment"
|
|
uses: docker/setup-qemu-action@v1
|
|
with:
|
|
image: tonistiigi/binfmt:latest
|
|
platforms: all
|
|
|
|
- name: "[SETUP] Determine Docker tag"
|
|
id: tag
|
|
uses: cytopia/docker-tag-action@v0.4.15
|
|
|
|
- name: "[SETUP] Set artifact names"
|
|
id: set-artifact-name
|
|
run: |
|
|
PRE_HASH="$( git rev-parse HEAD | head -c 10 )"
|
|
VERSION="${{ matrix.version }}"
|
|
ARCH="$( echo "${{ matrix.arch }}" | sed 's|/|-|g' )"
|
|
|
|
NAME_BASE="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-base"
|
|
NAME_MODS="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-mods"
|
|
NAME_PROD="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-prod"
|
|
NAME_WORK="${{ inputs.artifact_prefix }}-${PRE_HASH}-${VERSION}-${ARCH}-work"
|
|
|
|
echo "::set-output name=base::${NAME_BASE}"
|
|
echo "::set-output name=mods::${NAME_MODS}"
|
|
echo "::set-output name=prod::${NAME_PROD}"
|
|
echo "::set-output name=work::${NAME_WORK}"
|
|
|
|
# ------------------------------------------------------------
|
|
# Artifact Import
|
|
# ------------------------------------------------------------
|
|
|
|
###
|
|
### Download and import base
|
|
###
|
|
- name: "[Artifact Load] Download base"
|
|
uses: Wandalen/wretry.action@v1.0.11
|
|
with:
|
|
action: actions/download-artifact@v3
|
|
with: |
|
|
name: ${{ steps.set-artifact-name.outputs.base }}
|
|
attempt_limit: 20
|
|
attempt_delay: 10000
|
|
|
|
- name: "[Artifact Load] Import base"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make load INFILE=${{ steps.set-artifact-name.outputs.base }}
|
|
|
|
###
|
|
### Download and import mods
|
|
###
|
|
- name: "[Artifact Load] Download mods"
|
|
uses: Wandalen/wretry.action@v1.0.11
|
|
with:
|
|
action: actions/download-artifact@v3
|
|
with: |
|
|
name: ${{ steps.set-artifact-name.outputs.mods }}
|
|
attempt_limit: 20
|
|
attempt_delay: 10000
|
|
|
|
- name: "[Artifact Load] Import mods"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make load INFILE=${{ steps.set-artifact-name.outputs.mods }}
|
|
|
|
###
|
|
### Download and import prod
|
|
###
|
|
- name: "[Artifact Load] Download prod"
|
|
uses: Wandalen/wretry.action@v1.0.11
|
|
with:
|
|
action: actions/download-artifact@v3
|
|
with: |
|
|
name: ${{ steps.set-artifact-name.outputs.prod }}
|
|
attempt_limit: 20
|
|
attempt_delay: 10000
|
|
|
|
- name: "[Artifact Load] Import prod"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make load INFILE=${{ steps.set-artifact-name.outputs.prod }}
|
|
|
|
###
|
|
### Download and import prod
|
|
###
|
|
- name: "[Artifact Load] Download work"
|
|
uses: Wandalen/wretry.action@v1.0.11
|
|
with:
|
|
action: actions/download-artifact@v3
|
|
with: |
|
|
name: ${{ steps.set-artifact-name.outputs.work }}
|
|
attempt_limit: 20
|
|
attempt_delay: 10000
|
|
|
|
- name: "[Artifact Load] Import work"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make load INFILE=${{ steps.set-artifact-name.outputs.work }}
|
|
|
|
# ------------------------------------------------------------
|
|
# Re-tag images
|
|
# ------------------------------------------------------------
|
|
- name: "[Docker Tag] base"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make tag VERSION=${{ matrix.version }} FLAVOUR=base TAG=${{ steps.tag.outputs.docker-tag }}
|
|
|
|
- name: "[Docker Tag] mods"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make tag VERSION=${{ matrix.version }} FLAVOUR=mods TAG=${{ steps.tag.outputs.docker-tag }}
|
|
|
|
- name: "[Docker Tag] prod"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make tag VERSION=${{ matrix.version }} FLAVOUR=prod TAG=${{ steps.tag.outputs.docker-tag }}
|
|
|
|
- name: "[Docker Tag] work"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make tag VERSION=${{ matrix.version }} FLAVOUR=work TAG=${{ steps.tag.outputs.docker-tag }}
|
|
|
|
- name: "[Docker Tag] Show images"
|
|
run: |
|
|
docker images
|
|
|
|
|
|
# ------------------------------------------------------------
|
|
# Login
|
|
# ------------------------------------------------------------
|
|
- name: "Login"
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
if: ${{ inputs.can_deploy }}
|
|
|
|
|
|
# ------------------------------------------------------------
|
|
# Push images
|
|
# ------------------------------------------------------------
|
|
- name: "[Push Image] base"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make push VERSION=${{ matrix.version }} FLAVOUR=base TAG=${{ steps.tag.outputs.docker-tag }}
|
|
if: ${{ inputs.can_deploy }}
|
|
|
|
- name: "[Push Image] mods"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make push VERSION=${{ matrix.version }} FLAVOUR=mods TAG=${{ steps.tag.outputs.docker-tag }}
|
|
if: ${{ inputs.can_deploy }}
|
|
|
|
- name: "[Push Image] prod"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make push VERSION=${{ matrix.version }} FLAVOUR=prod TAG=${{ steps.tag.outputs.docker-tag }}
|
|
if: ${{ inputs.can_deploy }}
|
|
|
|
- name: "[Push Image] work"
|
|
uses: cytopia/shell-command-retry-action@v0.1.2
|
|
with:
|
|
command: |
|
|
make push VERSION=${{ matrix.version }} FLAVOUR=work TAG=${{ steps.tag.outputs.docker-tag }}
|
|
if: ${{ inputs.can_deploy }}
|