-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (53 loc) · 2.41 KB
/
Copy pathsync-initializr.yml
File metadata and controls
63 lines (53 loc) · 2.41 KB
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
name: Sync Spring Initializr Metadata
on:
schedule:
- cron: '0 0 * * *' # Run nightly at midnight UTC
workflow_dispatch: # Allow manual trigger via GitHub Actions UI
permissions:
contents: write
pull-requests: write
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
token: ${{ secrets.PAT }}
- name: Create resources folder
run: mkdir -p resources
- name: Fetch and format Initializr metadata
run: |
echo "Fetching metadata from start.spring.io/metadata/client..."
curl -sS -H "Accept: application/json" "https://start.spring.io/metadata/client" -o resources/initializr-metadata.raw.json
jq . resources/initializr-metadata.raw.json > resources/initializr-metadata.json
echo "Fetching dependencies from start.spring.io/dependencies..."
curl -sS -H "Accept: application/vnd.initializr.v2.2+json" "https://start.spring.io/dependencies" -o resources/dependencies.raw.json
jq . resources/dependencies.raw.json > resources/dependencies.json
rm resources/*.raw.json
- name: Create PR with changes
env:
GH_TOKEN: ${{ secrets.PAT }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add resources/initializr-metadata.json resources/dependencies.json
if git diff --staged --quiet; then
echo "No changes in metadata found. Skipping."
else
BRANCH="chore/sync-initializr-metadata"
git checkout -b "$BRANCH"
git commit -m "chore: sync Spring Initializr metadata and dependencies"
git push --force origin "$BRANCH"
EXISTING_PR=$(gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number')
if [ -n "$EXISTING_PR" ]; then
echo "PR #$EXISTING_PR already exists. Updated the branch."
else
gh pr create \
--title "chore: sync Spring Initializr metadata and dependencies" \
--body "Automated nightly sync of Spring Initializr metadata and dependencies." \
--head "$BRANCH" \
--base main
echo "Created new PR."
fi
fi