This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
62 lines (61 loc) · 2.33 KB
/
collect-rke2-release-notes.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
name: Collect RKE2 release notes
on:
workflow_dispatch:
schedule:
- cron: '40 8,20 * * *'
permissions:
contents: write
pull-requests: write
jobs:
collect-rke2:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
- name: Run scripts
id: run
run: |
bash scripts/collect-rke2-release-notes.sh
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
- name: Check for repository changes
run: |
if git diff --name-only --exit-code && test -z "$(git ls-files --exclude-standard --others)"; then
echo "No changes found in repository"
echo "changes_exist=false" >> $GITHUB_ENV
else
echo "Changes found in repository"
git diff --name-only
echo "changes_exist=true" >> $GITHUB_ENV
fi
- name: Create branch, commit and push
if: ${{ env.changes_exist == 'true' }}
id: branch
run: |
BRANCH="githubaction-collect-rke2-$(date +%Y-%m-%d-%H-%M-%S)"
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b "$BRANCH"
git add release-notes
git add kdm
git commit -a -m "Update generated content"
git push origin "$BRANCH"
- name: Create Pull Request
if: ${{ env.changes_exist == 'true' }}
id: cpr
env:
SOURCE_BRANCH: ${{ steps.branch.outputs.branch }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_TITLE: "Update generated content"
run: |
PR_BODY="Auto-generated by GitHub Actions"
CREATED_PR=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}" --label "status/auto-created" --base "${GITHUB_REF_NAME}" --head "${SOURCE_BRANCH}")
echo "Created pull request: ${CREATED_PR}" >> $GITHUB_STEP_SUMMARY
echo "PR=${CREATED_PR}" >> $GITHUB_OUTPUT
- name: Merge Pull Request
if: ${{ env.changes_exist == 'true' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr merge ${{ steps.cpr.outputs.PR }} --merge --delete-branch