mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-03-17 20:34:51 +08:00
68 lines
2.5 KiB
YAML
68 lines
2.5 KiB
YAML
name: Build PHP
|
|
|
|
on:
|
|
push:
|
|
branches: [ master ]
|
|
paths:
|
|
- ".github/workflows/**.yml"
|
|
- "docker/**"
|
|
|
|
jobs:
|
|
integration:
|
|
name: Build PHP ${{ matrix.php-versions }} for ${{ matrix.arch }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
php-versions: [ "7.2.34", "7.3.33", "7.4.30", "8.0.22", "8.1.9" ]
|
|
arch: [ "x86_64", "aarch64", "armv7l" ]
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- name: Check Dockerfile to ${{ matrix.arch }}
|
|
run: |
|
|
cd docker/
|
|
if [[ "${{ matrix.arch }}" != "x86_64" ]]; then
|
|
if [[ "${{ matrix.arch }}" = "armv7l" ]]; then
|
|
sed -ie 's/alpine:latest/multiarch\/alpine:armv7-edge/g' Dockerfile
|
|
else
|
|
sed -ie 's/alpine:latest/multiarch\/alpine:${{ matrix.arch }}-edge/g' Dockerfile
|
|
fi
|
|
docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
|
fi
|
|
- name: Build micro and PHP distribution ${{ matrix.php-versions }} for ${{ matrix.arch }}
|
|
id: buildphp
|
|
run: |
|
|
cd docker/ && docker build . --tag static-php --build-arg USE_BACKUP_ADDRESS=yes && \
|
|
mkdir ../dist && \
|
|
docker run --rm -v $(pwd)/../dist:/dist/ static-php build-php original ${{ matrix.php-versions }} all /dist/
|
|
- name: Fail if anything failed
|
|
if: steps.buildphp == 'failure'
|
|
run: |
|
|
false
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: static-php-cli_${{ matrix.php-versions }}_${{ matrix.arch }}
|
|
path: |
|
|
dist
|
|
- name: Pack PHP ${{ matrix.php-versions }} to archive
|
|
run: |
|
|
cd dist
|
|
tar -zcvf "php-${{ matrix.php-versions }}-static-bin-${{ matrix.arch }}.tar.gz" ./php && rm ./php
|
|
if [ -f "./micro.sfx" ]; then
|
|
tar -zcvf "micro-${{ matrix.php-versions }}-${{ matrix.arch }}.tar.gz" ./micro.sfx && rm ./micro.sfx
|
|
fi
|
|
- name: Deploy to Zhamao Server
|
|
uses: easingthemes/ssh-deploy@main
|
|
env:
|
|
SSH_PRIVATE_KEY: ${{ secrets.DEPLOY_SERVER_SECRET_KEY }}
|
|
ARGS: "-rltgoDzvO"
|
|
SOURCE: "dist/"
|
|
REMOTE_HOST: ${{ secrets.DEPLOY_SERVER_HOST }}
|
|
REMOTE_PORT: ${{ secrets.DEPLOY_SERVER_PORT }}
|
|
REMOTE_USER: ${{ secrets.DEPLOY_SERVER_USER }}
|
|
TARGET: ${{ secrets.DEPLOY_SERVER_TARGET }}
|
|
- name: Remove dist directory
|
|
run: |
|
|
rm -rf dist/
|
|
docker images | grep -v REPOSITORY | awk '{print $3}' | xargs docker rmi --force
|