Skip to content

Collect RKE release notes #146

Collect RKE release notes

Collect RKE release notes #146

name: Collect RKE release notes
on:
workflow_dispatch:
schedule:
- cron: '40 11,23 * * *'
permissions:
contents: write
pull-requests: write
jobs:
collect-rke:
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-rke-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-rke-$(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, initiated by @${GITHUB_ACTOR}"
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