This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
Collect k3s release notes #355
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Collect k3s release notes | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '40 6,18 * * *' | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
collect-k3s: | |
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-k3s-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-k3s-$(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 |