|
| 1 | +name: Get PHP Releases for each version |
| 2 | +on: |
| 3 | + workflow_dispatch: {} |
| 4 | + schedule: |
| 5 | + - cron: '15 12 * * *' # Daily at 12:15 UTC (15 min after main releases fetch) |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - main |
| 9 | + paths: |
| 10 | + - php-releases/releases.json |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: get-specific-php-releases |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + get-new-versions: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - name: Check out code |
| 21 | + uses: actions/checkout@v6 |
| 22 | + |
| 23 | + - name: Checkout Branch |
| 24 | + uses: paketo-buildpacks/github-config/actions/pull-request/checkout-branch@main |
| 25 | + with: |
| 26 | + branch: automation/php-releases/update |
| 27 | + |
| 28 | + - name: Get PHP Versions |
| 29 | + id: fetch |
| 30 | + run: | |
| 31 | + set -euo pipefail |
| 32 | +
|
| 33 | + versions=($(jq -r 'keys | .[]' php-releases/releases.json)) |
| 34 | + echo "📦 Found ${#versions[@]} PHP version lines: ${versions[*]}" |
| 35 | +
|
| 36 | + for version in "${versions[@]}"; do |
| 37 | + echo "Fetching releases for PHP $version..." |
| 38 | + output_file="php-releases/php-$version.json" |
| 39 | +
|
| 40 | + curl --silent --show-error --fail --http2 \ |
| 41 | + "https://www.php.net/releases/index.php?json&version=$version&max=1000" \ |
| 42 | + --output "$output_file" |
| 43 | +
|
| 44 | + done |
| 45 | +
|
| 46 | + - name: Check for Changes |
| 47 | + id: changes |
| 48 | + run: | |
| 49 | + if git diff --exit-code php-releases/php-*.json > /dev/null 2>&1; then |
| 50 | + echo "has-changes=false" >> "$GITHUB_OUTPUT" |
| 51 | + else |
| 52 | + echo "has-changes=true" >> "$GITHUB_OUTPUT" |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Commit |
| 56 | + if: ${{ steps.changes.outputs.has-changes == 'true' }} |
| 57 | + id: commit |
| 58 | + uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main |
| 59 | + with: |
| 60 | + message: "Update PHP releases for each version" |
| 61 | + pathspec: "php-releases/php-*.json" |
| 62 | + keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }} |
| 63 | + key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }} |
| 64 | + |
| 65 | + - name: Push Branch |
| 66 | + if: ${{ steps.commit.outputs.commit_sha != '' }} |
| 67 | + uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main |
| 68 | + with: |
| 69 | + branch: automation/php-releases/update |
| 70 | + |
| 71 | + - name: Create Pull Request |
| 72 | + if: ${{ steps.commit.outputs.commit_sha != '' }} |
| 73 | + uses: paketo-buildpacks/github-config/actions/pull-request/open@main |
| 74 | + with: |
| 75 | + token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }} |
| 76 | + title: "Updates PHP releases for each version" |
| 77 | + branch: automation/php-releases/update |
| 78 | + |
| 79 | + failure: |
| 80 | + name: Alert on Failure |
| 81 | + runs-on: ubuntu-latest |
| 82 | + needs: [get-new-versions] |
| 83 | + if: ${{ always() && needs.get-new-versions.result == 'failure' }} |
| 84 | + steps: |
| 85 | + - name: File Failure Alert Issue |
| 86 | + uses: paketo-buildpacks/github-config/actions/issue/file@main |
| 87 | + with: |
| 88 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 89 | + repo: ${{ github.repository }} |
| 90 | + label: "failure:get-specific-php-releases" |
| 91 | + comment_if_exists: true |
| 92 | + issue_title: "Failure: Get Specific PHP Version Releases workflow" |
| 93 | + issue_body: | |
| 94 | + Get Specific PHP Version Releases workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). |
| 95 | + comment_body: | |
| 96 | + Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} |
0 commit comments