resomi jumping system #597
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: Update Changelog | |
on: | |
push: | |
branches: | |
- Starlight | |
permissions: | |
contents: write | |
pull-requests: read | |
jobs: | |
update-changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get Pull Request Number | |
id: get_pr | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
echo "Commit message: $COMMIT_MESSAGE" | |
PR_NUMBER=$(echo "$COMMIT_MESSAGE" | grep -oP '(?<=Merge pull request #)\d+' || true) | |
if [ -z "$PR_NUMBER" ]; then | |
echo "No PR number found in commit message. Skipping changelog update." | |
echo "::set-output name=PR_NUMBER::" | |
exit 0 | |
fi | |
echo "PR Number: $PR_NUMBER" | |
echo "::set-output name=PR_NUMBER::$PR_NUMBER" | |
- name: Set up Python | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install Dependencies | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
run: | | |
pip install pyyaml PyGithub | |
- name: Parse PR and Update Changelog | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
env: | |
CHANGELOG_FILE_PATH: 'Resources/Changelog/ChangelogStarlight.yml' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PR_NUMBER: ${{ steps.get_pr.outputs.PR_NUMBER }} | |
GITHUB_REPOSITORY: ${{ github.repository }} | |
run: | | |
python ./Tools/_Starlight/update_changelog.py | |
echo "Script exited with code $?" | |
- name: Display changelog after update | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
run: | | |
cat "Resources/Changelog/ChangelogStarlight.yml" | |
- name: Git status before commit | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
run: | | |
git status | |
- name: Commit and push changes | |
if: steps.get_pr.outputs.PR_NUMBER != '' | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add "Resources/Changelog/ChangelogStarlight.yml" | |
if git diff --cached --quiet; then | |
echo "No changes to commit." | |
else | |
git pull origin HEAD:Starlight | |
git commit -m "Update changelog for PR #${{ steps.get_pr.outputs.PR_NUMBER }} [skip ci]" | |
git push origin HEAD:Starlight | |
fi | |