Process Artisan Commands #1031
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: Process Artisan Commands | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- '!dependabot/**' | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0,12,22 * * *' | |
jobs: | |
fetch_laravel_versions: | |
name: Discover Latest Laravel Versions | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.fetch_versions.outputs.matrix }} | |
steps: | |
- name: Fetch from Packagist | |
id: fetch_versions | |
run: | | |
# Fetch the latest Laravel versions from Packagist | |
# Convert to JSON e.g {v: "8", php: ">=7.3.0"} | |
# Extract the versions and their PHP requirements | |
# Remove duplicate lines based on the first column | |
# Get major v only, dedupe, and combine on one line | |
# Output the JSON to the step output | |
curl -s https://packagist.org/packages/laravel/laravel.json?$(date +%F%H%M) \ | |
| jq -r '.package.versions[] | select(.require.php != null) | select(.version_normalized != null) | .version_normalized, .require.php' \ | |
| sed -e '/dev/,+1d' -e '1~2 s/\..*//' -e '2~2 s/[^|]*|//' -e 's/[^0-9]*//' \ | |
| cut -f1,2 -d'.' \ | |
| awk 'NR%2{printf "%s ",$0;next;}1' \ | |
| sort -Vru -k1,1 \ | |
| jq -Rcn '[inputs | split(" ") | {v:.[0], php:.[1]}]' \ | |
| tee /tmp/versions.json | |
echo "matrix=$(cat /tmp/versions.json)" >> "$GITHUB_OUTPUT" | |
generate: | |
needs: fetch_laravel_versions | |
name: Laravel ${{ matrix.laravel.v }}.x - PHP ${{ matrix.laravel.php }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
laravel: ${{ fromJson(needs.fetch_laravel_versions.outputs.matrix) }} | |
exclude: | |
- laravel: | |
php: '8.0' | |
v: 9 | |
permissions: | |
# Give the default GITHUB_TOKEN write permission to commit and push the | |
# added or changed files to the repository. | |
contents: write | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Setup PHP | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.laravel.php }} | |
tools: composer:v2 | |
- name: Install Laravel | |
run: composer create-project --no-progress laravel/laravel="^${{ matrix.laravel.v }}" --stability=beta --prefer-dist /tmp/laravel | |
- name: Configure PHP Platform | |
run: | | |
cd /tmp/laravel | |
composer config platform.php ${{ matrix.laravel.php }} --file composer.json | |
- name: Add Laravel Nova Repository | |
run: | | |
cd /tmp/laravel | |
composer config repositories.nova '{"type": "composer", "url": "https://nova.laravel.com"}' --file composer.json | |
composer config --global http-basic.nova.laravel.com "${{ secrets.NOVA_USERNAME }}" "${{ secrets.NOVA_LICENSE_KEY }}" | |
- name: Add Laravel Spark Repository | |
run: | | |
cd /tmp/laravel | |
composer config repositories.spark '{"type": "composer", "url": "https://spark.laravel.com"}' --file composer.json | |
composer config --global http-basic.spark.laravel.com "${{ secrets.SPARK_USERNAME }}" "${{ secrets.SPARK_API_TOKEN }}" | |
- name: Install Laravel Packages | |
run: | | |
cd /tmp/laravel | |
echo "Installing Laravel ${{ matrix.laravel.v }} Packages" | |
PACKAGES=$(jq '.configuration["${{ matrix.laravel.v }}.x"] | .[]' ${{ github.workspace }}/manifest.json) | |
for PACKAGE in $PACKAGES; do | |
composer require --no-progress --no-interaction --ignore-platform-reqs -W $(echo $PACKAGE | xargs echo) || true | |
done | |
continue-on-error: true | |
- name: Run Generator Command | |
run: | | |
cd /tmp/laravel | |
cp ${{ github.workspace }}/build.php /tmp/laravel/ | |
BUILD_OUTPUT=$(php -f /tmp/laravel/build.php) | |
if [[ $? -eq 0 ]]; then | |
echo $BUILD_OUTPUT > /tmp/${{ matrix.laravel.v }}.x.json | |
cp /tmp/${{ matrix.laravel.v }}.x.json ${{ github.workspace }}/assets/ | |
else | |
echo "Build failed" | |
exit 1 | |
fi | |
- name: Sync Git Changes | |
run: git pull origin ${GITHUB_REF##*/} || true # can be run safely as only .x.json files are changed | |
- name: Commit Laravel Version | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: | | |
Build Laravel ${{ matrix.laravel.v }}.x | |
[skip ci] [ci skip] | |
pull: ' ' | |
add: assets/${{ matrix.laravel.v }}.x.json |