Skip to content

Commit 9ba72a0

Browse files
Add PHP version workflows (#974)
1 parent 6586456 commit 9ba72a0

2 files changed

Lines changed: 172 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Get PHP Releases
2+
on:
3+
workflow_dispatch: {}
4+
schedule:
5+
- cron: '0 12 * * *' # Daily at 12:00 UTC (noon)
6+
7+
concurrency:
8+
group: get-php-releases
9+
cancel-in-progress: false
10+
11+
jobs:
12+
get-new-versions:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v6
17+
18+
- name: Get PHP Versions
19+
id: fetch
20+
run: |
21+
curl --silent --show-error --fail \
22+
https://www.php.net/releases/index.php?json \
23+
--http2 \
24+
--output php-releases/releases.json
25+
26+
- name: Check for Changes
27+
id: changes
28+
run: |
29+
if git diff --exit-code php-releases/releases.json > /dev/null 2>&1; then
30+
echo "has-changes=false" >> "$GITHUB_OUTPUT"
31+
else
32+
echo "has-changes=true" >> "$GITHUB_OUTPUT"
33+
fi
34+
35+
- name: Commit
36+
if: ${{ steps.changes.outputs.has-changes == 'true' }}
37+
id: commit
38+
uses: paketo-buildpacks/github-config/actions/pull-request/create-commit@main
39+
with:
40+
message: "Update PHP releases"
41+
pathspec: "php-releases/releases.json"
42+
keyid: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY_ID }}
43+
key: ${{ secrets.PAKETO_BOT_GPG_SIGNING_KEY }}
44+
45+
- name: Push Branch
46+
if: ${{ steps.commit.outputs.commit_sha != '' }}
47+
uses: paketo-buildpacks/github-config/actions/pull-request/push-branch@main
48+
with:
49+
branch: automation/php-releases/update
50+
51+
- name: Create Pull Request
52+
if: ${{ steps.commit.outputs.commit_sha != '' }}
53+
uses: paketo-buildpacks/github-config/actions/pull-request/open@main
54+
with:
55+
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
56+
title: "Updates PHP releases"
57+
branch: automation/php-releases/update
58+
59+
failure:
60+
name: Alert on Failure
61+
runs-on: ubuntu-latest
62+
needs: [get-new-versions]
63+
if: ${{ always() && needs.get-new-versions.result == 'failure' }}
64+
steps:
65+
- name: File Failure Alert Issue
66+
uses: paketo-buildpacks/github-config/actions/issue/file@main
67+
with:
68+
token: ${{ secrets.GITHUB_TOKEN }}
69+
repo: ${{ github.repository }}
70+
label: "failure:get-php-releases"
71+
comment_if_exists: true
72+
issue_title: "Failure: Get PHP Releases workflow"
73+
issue_body: |
74+
Get PHP Releases workflow [failed](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}).
75+
comment_body: |
76+
Another failure occurred: https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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

Comments
 (0)