forked from Async-AWS-PR/commits-since-release-counter
-
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (68 loc) · 2.47 KB
/
watch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Update source images
on:
workflow_dispatch:
schedule:
- cron: '45 * * * *'
jobs:
update:
name: Update source code
runs-on: ubuntu-latest
steps:
- name: Fetch data
id: fetch
run: |
# Fetch your JSON manifest from GitHub (or wherever it’s hosted)
data=$(curl -s https://raw.githubusercontent.com/flow-php/flow/refs/heads/1.x/manifest.json)
# Use 'jq' to extract the `.packages[].name` fields as a space-separated list
repos=$(echo "$data" | jq -r '.packages[].name')
echo "Here are the listed repos: $repos"
echo "::set-output name=repos::$repos"
- name: Set up PHP
uses: shivammathur/[email protected]
with:
php-version: 8.2
- name: Checkout code
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: Download dependencies
run: |
composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Compare & Print
run: |
# Loop over each repository name we got from the 'Fetch data' step
for REPOSITORY in ${{ steps.fetch.outputs.repos }}
do
echo "::group::$REPOSITORY"
# Clone the repository (1.x branch as in the original example)
git clone --branch 1.x https://${{ secrets.GH_TOKEN }}:[email protected]/$REPOSITORY output
cd output
# Count how many commits happened since the last tag
count=$(git rev-list --count $(git describe --abbrev=0 --tags)..HEAD)
cd ..
rm -rf output
# Example call to your PHP script
php ./src/image.php $REPOSITORY $count
echo "::endgroup::"
done
- name: Commit changes
run: |
echo "::group::git status"
git status
echo "::endgroup::"
git add -N docs
if [[ $(git diff --numstat | wc -l) -eq 0 ]]; then
echo "No changes found. Exiting."
exit 0;
fi
git config --local user.email "[email protected]"
git config --local user.name "Flow PHP Bot"
echo "::group::git push"
git add docs/*
git commit -m "Update images with new data"
echo "::endgroup::"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GH_TOKEN }}