Build PHP #50
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 PHP | |
on: | |
workflow_call: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: "0 6 * * 2" # 6am Patch Tuesday | |
permissions: | |
contents: read | |
packages: write | |
concurrency: | |
group: ${{ github.head_ref || github.run_id }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: "Build PHP Flavours" | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
max-parallel: 15 | |
matrix: | |
variant: | |
- cli | |
- nginx | |
- apache | |
version: | |
# - "7.0" | |
# - "7.1" | |
# - "7.2" | |
# - "7.3" | |
# - "7.4" | |
# - "8.0" | |
# - "8.1" | |
- "8.2" | |
- "8.3" | |
env: | |
PHP_PACKAGES_70: git mariadb-client php7.0-apcu php7.0-bcmath php7.0-bz2 php7.0-cli php7.0-curl php7.0-gd php7.0-imap php7.0-imagick php7.0-intl php7.0-json php7.0-ldap php7.0-mbstring php7.0-mcrypt php7.0-memcache php7.0-memcached php7.0-mongodb php7.0-mysql php7.0-opcache php7.0-pgsql php7.0-phpdbg php7.0-pspell php7.0-redis php7.0-soap php7.0-sqlite php7.0-xdebug php7.0-xml php7.0-zip postgresql-client | |
PHP_PACKAGES_71: git mariadb-client php7.1-apcu php7.1-bcmath php7.1-bz2 php7.1-cli php7.1-curl php7.1-gd php7.1-imap php7.1-imagick php7.1-intl php7.1-json php7.1-ldap php7.1-mbstring php7.1-mcrypt php7.1-memcache php7.1-memcached php7.1-mongodb php7.1-mysql php7.1-opcache php7.1-pgsql php7.1-phpdbg php7.1-pspell php7.1-redis php7.1-soap php7.1-sqlite php7.1-xdebug php7.1-xml php7.1-zip postgresql-client | |
PHP_PACKAGES_72: git mariadb-client php7.2-apcu php7.2-bcmath php7.2-bz2 php7.2-cli php7.2-curl php7.2-gd php7.2-imap php7.2-imagick php7.2-intl php7.2-json php7.2-ldap php7.2-mbstring php7.2-memcache php7.2-memcached php7.2-mongodb php7.2-mysql php7.2-opcache php7.2-pgsql php7.2-phpdbg php7.2-pspell php7.2-redis php7.2-soap php7.2-sqlite php7.2-xdebug php7.2-xml php7.2-zip postgresql-client | |
PHP_PACKAGES_73: git htop mariadb-client php7.3-apcu php7.3-bcmath php7.3-bz2 php7.3-cli php7.3-curl php7.3-gd php7.3-imap php7.3-imagick php7.3-intl php7.3-json php7.3-ldap php7.3-mbstring php7.3-memcache php7.3-memcached php7.3-mongodb php7.3-mysql php7.3-opcache php7.3-pgsql php7.3-phpdbg php7.3-pspell php7.3-redis php7.3-soap php7.3-sqlite php7.3-xdebug php7.3-xml php7.3-zip postgresql-client | |
PHP_PACKAGES_74: git htop mariadb-client php7.4-apcu php7.4-bcmath php7.4-bz2 php7.4-cli php7.4-curl php7.4-gd php7.4-imap php7.4-imagick php7.4-intl php7.4-json php7.4-ldap php7.4-mbstring php7.4-memcache php7.4-mongodb php7.4-mysql php7.4-opcache php7.4-pgsql php7.4-phpdbg php7.4-pspell php7.4-redis php7.4-soap php7.4-sqlite php7.4-xdebug php7.4-xml php7.4-zip postgresql-client | |
PHP_PACKAGES_80: git htop mariadb-client php8.0-apcu php8.0-bcmath php8.0-bz2 php8.0-cli php8.0-curl php8.0-gd php8.0-imap php8.0-imagick php8.0-intl php8.0-ldap php8.0-mailparse php8.0-mbstring php8.0-memcache php8.0-mongodb php8.0-mysql php8.0-opcache php8.0-pgsql php8.0-phpdbg php8.0-pspell php8.0-redis php8.0-soap php8.0-sqlite php8.0-xdebug php8.0-xml php8.0-zip postgresql-client | |
PHP_PACKAGES_81: git htop mariadb-client php8.1-apcu php8.1-bcmath php8.1-bz2 php8.1-cli php8.1-curl php8.1-gd php8.1-imap php8.1-imagick php8.1-intl php8.1-ldap php8.1-mailparse php8.1-mbstring php8.1-memcache php8.1-mongodb php8.1-mysql php8.1-opcache php8.1-pgsql php8.1-phpdbg php8.1-pspell php8.1-redis php8.1-soap php8.1-sqlite php8.1-xdebug php8.1-xml php8.1-zip postgresql-client | |
PHP_PACKAGES_82: git htop mariadb-client php8.2-apcu php8.2-bcmath php8.2-bz2 php8.2-cli php8.2-curl php8.2-gd php8.2-imap php8.2-imagick php8.2-intl php8.2-ldap php8.2-mailparse php8.2-mbstring php8.2-memcache php8.2-mongodb php8.2-mysql php8.2-opcache php8.2-pgsql php8.2-phpdbg php8.2-pspell php8.2-redis php8.2-soap php8.2-sqlite php8.2-xdebug php8.2-xml php8.2-zip postgresql-client | |
PHP_PACKAGES_83: git htop mariadb-client php8.3-apcu php8.3-bcmath php8.3-bz2 php8.3-cli php8.3-curl php8.3-gd php8.3-imap php8.3-imagick php8.3-intl php8.3-ldap php8.3-mailparse php8.3-mbstring php8.3-memcache php8.3-mongodb php8.3-mysql php8.3-opcache php8.3-pgsql php8.3-phpdbg php8.3-pspell php8.3-redis php8.3-soap php8.3-sqlite php8.3-xdebug php8.3-xml php8.3-zip postgresql-client | |
COMPOSER_VERSION_70: 2.2.22 | |
COMPOSER_VERSION_71: 2.2.22 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Interpolate Envs | |
id: vars | |
run: | | |
{ | |
VERSION=$(echo "${{ matrix.version }}" | tr -d '.') | |
PACKAGE_LIST=PHP_PACKAGES_$VERSION | |
echo php_packages=${!PACKAGE_LIST} | |
COMPOSER_VERSION=COMPOSER_VERSION_$VERSION | |
echo composer_version=${!COMPOSER_VERSION:-"latest-stable"} | |
} >> "$GITHUB_OUTPUT" | |
- uses: actions/github-script@v7 | |
id: build_args | |
with: | |
result-encoding: string | |
script: return `PHP_PACKAGES=${{ steps.vars.outputs.php_packages }}\nPHP_VERSION=${{ matrix.version }}\nCOMPOSER_VERSION=${{ steps.vars.outputs.composer_version }}` | |
- uses: benzine-framework/action-setup-docker@main | |
with: | |
ghcr_user: matthewbaggett | |
ghcr_token: ${{ secrets.GITHUB_TOKEN }} | |
docker_hub_user: matthewbaggett | |
docker_hub_token: ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: Login to registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ secrets.PRIVATE_REGISTRY }} | |
username: ${{ secrets.PRIVATE_REGISTRY_USER }} | |
password: ${{ secrets.PRIVATE_REGISTRY_TOKEN }} | |
- uses: docker/build-push-action@v5 | |
name: "Build: Build & Push" | |
with: | |
context: . | |
target: php-${{ matrix.variant }} | |
platforms: ${{ !env.ACT && 'linux/amd64,linux/arm64' || 'linux/amd64' }} | |
build-contexts: | | |
marshall:build=docker-image://ghcr.io/benzine-framework/marshall:focal | |
pull: true | |
push: true | |
tags: | | |
ghcr.io/benzine-framework/php:${{ matrix.variant }}-${{ matrix.version }} | |
gone/php:${{ matrix.variant }}-${{ matrix.version }} | |
benzine/php:${{ matrix.variant }}-${{ matrix.version }} | |
${{ secrets.PRIVATE_REGISTRY }}/php:${{ matrix.variant }}-${{ matrix.version }} | |
build-args: | | |
${{ steps.build_args.outputs.result }} | |
cache-from: "${{ env.DOCKER_CACHE_FROM }},scope=${{ matrix.variant }}-${{ matrix.version }}" | |
cache-to: "${{ env.DOCKER_CACHE_TO }},scope=${{ matrix.variant }}-${{ matrix.version }}" | |
- name: "Validate build" | |
run: docker run --rm ghcr.io/benzine-framework/php:${{ matrix.variant }}-${{ matrix.version }} /usr/bin/install-report | |
validate-dive-report: | |
name: Run Dive | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
max-parallel: 15 | |
matrix: | |
variant: | |
- cli | |
- nginx | |
- apache | |
version: | |
# - "7.0" | |
# - "7.1" | |
# - "7.2" | |
# - "7.3" | |
# - "7.4" | |
# - "8.0" | |
# - "8.1" | |
- "8.2" | |
- "8.3" | |
steps: | |
- run: docker login ghcr.io -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} | |
- name: "Pull Candidate Image" | |
run: docker pull ghcr.io/benzine-framework/php:${{ matrix.variant }}-${{ matrix.version }} | |
- name: "Generate Dive Config" | |
run: | | |
{ | |
echo "rules:" | |
echo "lowestEfficiency: 0.95" | |
echo "highestWastedBytes: 20MB" | |
echo "highestUserWastedPercent: 0.20" | |
} > ${{ github.workspace }}/.dive-ci.yml | |
# Use Dive to inspect the image for junk | |
- name: "Dive" | |
uses: yuichielectric/dive-action@0.0.3 | |
with: | |
image: ghcr.io/benzine-framework/php:${{ matrix.variant }}-${{ matrix.version }} | |
config-file: ${{ github.workspace }}/.dive-ci.yml | |
tags: | |
name: Vanity Tags | |
runs-on: ubuntu-latest | |
needs: | |
- build | |
env: | |
latest-stable-version: "8.3" | |
base_tag: "ghcr.io/benzine-framework/php" | |
strategy: | |
fail-fast: false | |
matrix: | |
variant: | |
- cli | |
- nginx | |
- apache | |
output_tag: | |
- "benzine/php" | |
- "gone/php" | |
- "ghcr.io/benzine-framework/php" | |
steps: | |
- run: docker login ghcr.io -u ${{ github.repository_owner }} -p ${{ secrets.GITHUB_TOKEN }} | |
- run: docker login docker.io -u matthewbaggett -p ${{ secrets.DOCKER_HUB_TOKEN }} | |
- name: "Retag ${{ env.base_tag }}:${{ matrix.variant }}-${{ env.latest-stable-version }} to ${{ matrix.output_tag }}:${{ matrix.variant }}" | |
if: ${{ github.ref == 'refs/heads/main' }} | |
shell: bash | |
run: | | |
docker pull ${{ env.base_tag }}:${{ matrix.variant }}-${{ env.latest-stable-version }} | |
docker tag ${{ env.base_tag }}:${{ matrix.variant }}-${{ env.latest-stable-version }} ${{ matrix.output_tag }}:${{ matrix.variant }} | |
docker push ${{ matrix.output_tag }}:${{ matrix.variant }} |