Skip to content

Commit 3f41fff

Browse files
authored
Auto PRs for release updates (#220)
* feat: automate cadence release data onto documentation * fix: link * feat: automate updating the release data * add json validation * fix: don't tag RC as latest release for GA * docs: add java version compatibility * fetch release data automation improvements * fetch release data automation improvements
1 parent f587839 commit 3f41fff

File tree

1 file changed

+53
-11
lines changed

1 file changed

+53
-11
lines changed

.github/workflows/fetch-release-data.yml

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,67 @@ on:
66
workflow_dispatch:
77
permissions:
88
contents: write
9+
pull-requests: write
10+
11+
env:
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
BRANCH: fetch-release-data-update
14+
915
jobs:
1016
fetch-release-data:
1117
runs-on: ubuntu-latest
1218
steps:
13-
- uses: actions/checkout@v4
19+
- name: Try checkout ${{ env.BRANCH }}
20+
uses: actions/checkout@v4
21+
id: try-checkout
22+
continue-on-error: true
1423
with:
15-
sparse-checkout: |
16-
scripts
17-
static/data/releases
18-
- run: |
24+
ref: ${{ env.BRANCH }}
25+
26+
- name: Fallback to default branch if checkout failed
27+
if: steps.try-checkout.outcome == 'failure'
28+
uses: actions/checkout@v4
29+
with:
30+
ref: ${{ github.event.repository.default_branch }}
31+
32+
- name: Configure git
33+
run: |
34+
git config user.name "github-actions[bot]"
35+
git config user.email "github-actions[bot]@users.noreply.github.com"
36+
37+
- name: Ensure branch exists or create it
38+
run: |
39+
git fetch origin $BRANCH || true
40+
if git rev-parse --verify $BRANCH; then
41+
git checkout $BRANCH
42+
else
43+
git checkout -b $BRANCH
44+
fi
45+
46+
- name: Fetch release data and update
47+
id: fetch-release-data
48+
run: |
49+
# fetch release data
1950
./scripts/fetch-releases.sh
51+
52+
# exit if there are no changes to be made
2053
if git diff --quiet static/data/releases; then
54+
echo "skip_pr=true" >> $GITHUB_OUTPUT
2155
echo "No changes to commit"
2256
exit 0
2357
fi
24-
git config user.name "github-actions[bot]"
25-
git config user.email "github-actions[bot]@users.noreply.github.com"
58+
59+
job_url=$(gh run --repo ${{ github.repository }} view ${{ github.run_id }} --json jobs --jq '.jobs[] | select(.name == "${{ github.job }}") | .url')
60+
61+
# commit and push changes
2662
git add static/data/releases
27-
git commit -m "Update release data"
28-
git push
29-
env:
30-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63+
git commit -m "Update release data" -m "Job: $job_url"
64+
git push origin $BRANCH
65+
66+
- name: Open a PR if needed
67+
if: ${{ steps.fetch-release-data.outputs.skip_pr != 'true' }}
68+
run: |
69+
prs=$(gh pr list --repo "$GITHUB_REPOSITORY" --head "$BRANCH" --base 'master' --json title --jq 'length')
70+
if ((prs == 0)); then
71+
gh pr create -B master -H $BRANCH --title 'Update Cadence Release Data' --body "Created by Github action"
72+
fi

0 commit comments

Comments
 (0)