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: | |
- master | |
workflow_dispatch: | |
schedule: | |
- cron: '0 0 * * 3' | |
jobs: | |
fetch_laravel_versions: | |
name: Fetch Latest Laravel Versions | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.fetch_versions.outputs.matrix }} | |
steps: | |
- name: Get versions 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 | |
# Remove v5.x versions as the putput breaks | |
# 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 \ | |
| 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 \ | |
| sed '/^5 /d' \ | |
| 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 v${{ matrix.laravel.v }} - PHP ${{ matrix.laravel.php }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
laravel: ${{ fromJson(needs.fetch_laravel_versions.outputs.matrix) }} | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Set up git user | |
run: | | |
git config --global user.name ${GITHUB_ACTOR} | |
git config --global user.email ${GITHUB_ACTOR}@users.noreply.github.com | |
- name: Setup PHP, with Composer and extensions | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: ${{ matrix.laravel.php }} | |
extensions: dom, curl, libxml, mbstring, zip | |
tools: composer:v2 | |
- name: Install Laravel | |
run: composer create-project --no-progress laravel/laravel="^${{ matrix.laravel.v }}" /tmp/laravel | |
- name: Run Generator Command | |
run: | | |
cd /tmp/laravel | |
cat ${{ github.workspace }}/build | php artisan tinker > /tmp/${{ matrix.laravel.v }}.x.json | true | |
- name: Commit comand files if needed #it fails if nothing has changed so we allow an error | |
run: | | |
n=0 | |
until [ "$n" -ge 10 ] | |
do | |
git fetch --all | |
git reset --hard HEAD | |
git clean -f -d | |
git pull || true | |
cp /tmp/${{ matrix.laravel.v }}.x.json ./assets/ | |
git add -A || true | |
git commit -am 'Build Laravel version v${{ matrix.laravel.v }}' || true | |
git push --force && break | |
n=$((n+1)) | |
sleep 15 | |
done | |
env: | |
matrix: ${{ needs.fetch_laravel_versions.outputs.matrix }} | |
continue-on-error: true |