Skip to content

Daily build

Daily build #1140

Workflow file for this run

################################################################################
# These setups are part of the project: https://code.shin.company/php
# Please respect the intellectual effort that went into creating them.
# If you use or copy these ideas, proper credit would be appreciated.
# - Author: Mai Nhut Tan <shin@shin.company>
# - License: https://code.shin.company/php/blob/main/LICENSE
################################################################################
name: Daily build
################################################################################
################################################################################
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
release:
types: [released]
pull_request:
types: [opened]
paths:
- 'src/**'
- '!src/**.md'
################################################################################
################################################################################
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
tag_prefix: ${{ steps.init.outputs.tag_prefix }}
build_all: ${{ steps.init.outputs.build_all == '1' }}
steps:
- uses: actions/checkout@v4
- name: pre-build debug
id: init
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
set -e
. ./build/helpers.sh
# Prepare variables
the_day=$(date -u +"%d")
event_name=${{ github.event_name }}
ref_type=${{ github.ref_type }}
ref=${{ github.ref }}
tag_prefix=$(if [[ $ref_type != 'tag' ]] && [[ $ref != 'refs/heads/main' ]]; then echo 'dev-'; fi)
build_all=$(if [[ $event_name != 'schedule' ]] || [[ $the_day == '01' ]]; then echo '1'; fi)
# For debugging purposes
echo "the_day=$the_day" >> "$GITHUB_OUTPUT"
echo "tag_prefix=$tag_prefix" >> "$GITHUB_OUTPUT"
echo "build_all=$build_all" >> "$GITHUB_OUTPUT"
echo "number_of_cores = $(nproc)"
echo "github.event_name = $event_name"
echo "github.ref_type = $ref_type"
echo "github.ref = $ref"
echo "tag_prefix = $tag_prefix"
echo "build_all = $(if [ -n "$build_all" ]; then echo 'yes, includes outdated versions'; else echo 'no, only maintained versions'; fi)"
# Cache requests
echo "Generating cache keys..."
get_github_latest_tag "composer/composer"
get_github_latest_tag "just-containers/s6-overlay"
get_github_latest_tag "mlocati/docker-php-extension-installer"
get_github_latest_tag "roadrunner-server/roadrunner"
get_dockerhub_latest_sha "library/debian"
get_dockerhub_latest_sha "library/alpine"
get_dockerhub_latest_sha "library/ubuntu"
distros=(debian alpine)
variants=(cli fpm zts)
base_images=(phpfpm-nginx phpfpm-apache laravel)
php_versions=(8.5 8.4 8.3 8.2)
if [ -n "$build_all" ]; then
php_versions+=(8.1 8.0 7.4 7.3 7.2 7.1 7.0 5.6)
fi
get_sha() {
get_dockerhub_latest_sha "$@" || true
}
for distro in "${distros[@]}"; do
get_sha "library/$distro"
if [ "$distro" == "debian" ]; then
distro=""
fi
for version in "${php_versions[@]}"; do
for variant in "${variants[@]}"; do
get_sha "library/php" 1 "${version}-${variant}-${distro}"
if [ "$variant" == "zts" ] && verlte "8.2" "$version"; then
get_sha "dunglas/frankenphp" 1 "1-php${version}-${distro}"
fi
done
# for base in "${base_images[@]}"; do
# get_sha "shinsenter/$base" 1 "${tag_prefix}php${version//-rc/}-${distro}"
# done
done
done
- uses: actions/upload-artifact@v4
with:
name: helper_cache
overwrite: true
path: /tmp/helper_cache/
##########################################################
s6-overlay:
uses: ./.github/workflows/template-common.yml
secrets: inherit
needs: [prepare]
with:
app_name: "base-s6"
os: "alpine"
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
linux-s6:
name: ${{ matrix.os == '' && 'debian' || matrix.os }}-s6
uses: ./.github/workflows/template-common.yml
secrets: inherit
needs: [prepare]
strategy:
fail-fast: false
matrix:
os:
- ""
- "ubuntu"
- "alpine"
with:
app_name: "base-os"
os: ${{ matrix.os }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
##########################################################
php-fpm:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare]
strategy:
fail-fast: false
matrix:
app:
- fpm
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
php-cli:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare]
strategy:
fail-fast: false
matrix:
app:
- cli
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
php-zts:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare]
strategy:
fail-fast: false
matrix:
app:
- zts
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
##########################################################
fpm-servers:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, s6-overlay, php-fpm]
strategy:
fail-fast: false
matrix:
app:
- with-apache
- with-nginx
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
zts-servers:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, s6-overlay, php-zts]
strategy:
fail-fast: false
matrix:
app:
- with-f8p
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
cli-servers:
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, s6-overlay, php-cli]
strategy:
fail-fast: false
matrix:
app:
- with-roadrunner
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
##########################################################
server-cache:
runs-on: ubuntu-22.04
needs: [prepare, cli-servers, fpm-servers]
steps:
- uses: actions/download-artifact@v4
with:
name: helper_cache
path: /tmp/helper_cache/
- uses: actions/checkout@v4
- name: Prepare cache
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }}
run: |
set -e
. ./build/helpers.sh
build_all="${{ needs.prepare.outputs.build_all }}"
echo "build_all = '$build_all' ($(if [ "$build_all" = "true" ]; then echo 'yes, includes outdated versions'; else echo 'no, only maintained versions'; fi))"
distros=(debian alpine)
base_images=(phpfpm-nginx phpfpm-apache roadrunner laravel)
php_versions=(8.5 8.4 8.3 8.2)
if [ "$build_all" = "true" ]; then
php_versions+=(8.1 8.0 7.4 7.3 7.2 7.1 7.0 5.6)
fi
get_sha() {
get_dockerhub_latest_sha "$@" || true
}
for distro in "${distros[@]}"; do
get_sha "library/$distro"
if [ "$distro" == "debian" ]; then
distro=""
fi
for version in "${php_versions[@]}"; do
if verlt "7.1" "$version" || [ "$distro" = "" ]; then
for base in "${base_images[@]}"; do
get_sha "shinsenter/$base" 1 "${tag_prefix}php${version//-rc/}-${distro}"
done
fi
done
done
ls -lh /tmp/helper_cache/ | awk '{ if(NR>1) printf "%10s %s\n", $5, $9 }'
- uses: actions/upload-artifact@v4
with:
name: helper_cache
overwrite: true
path: /tmp/helper_cache/
##########################################################
popular-apps:
name: ${{ matrix.app }}
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, server-cache]
strategy:
fail-fast: false
matrix:
app:
- app-cakephp4
- app-cakephp5
- app-codeigniter4
- app-drupal
- app-espocrm
- app-flarum
- app-flightphp
- app-grav
- app-hyperf
- app-kirby
- app-laminas
- app-laravel
- app-magento
- app-matomo
- app-mautic
- app-phpmyadmin
- app-slim
- app-symfony
- app-wordpress
- app-yii
server:
- ""
# include:
# - app: app-laravel
# server: apache
# - app: app-laravel
# server: nginx
with:
app_name: ${{ matrix.app }}
server: ${{ matrix.server }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
other-apps:
name: ${{ matrix.app }}
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, server-cache]
strategy:
fail-fast: false
matrix:
app:
- app-spiral
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
extended-apps:
name: ${{ matrix.app }}
uses: ./.github/workflows/template-php.yml
secrets: inherit
needs: [prepare, popular-apps]
strategy:
fail-fast: false
matrix:
app:
- app-bagisto
- app-bedrock
- app-coolify
- app-hypervel
- app-invoiceshelf
- app-statamic
- app-sulu
with:
app_name: ${{ matrix.app }}
tag_prefix: ${{ needs.prepare.outputs.tag_prefix }}
build_all: ${{ fromJSON(needs.prepare.outputs.build_all) || false }}
################################################################################
################################################################################