Workflow file for this run
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: Extract Release Notes to Wiki | |
on: | |
release: | |
types: | |
- published | |
- edited | |
env: | |
GH_TOKEN: ${{ github.token }} | |
jobs: | |
update-wiki: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Verify gh CLI | |
run: | | |
gh --version | |
gh auth status | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Checkout Code Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }} | |
path: code | |
- name: Checkout Wiki Repository | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.repository }}.wiki | |
path: wiki | |
- name: Extract Release Notes | |
run: | | |
# Change directory to the main code repository | |
cd $GITHUB_WORKSPACE/code | |
# Fetch the latest release notes | |
RELEASE_NOTES=$(gh release view ${{ github.event.release.tag_name }} --json body -q ".body") | |
# Define the file to update | |
cd $GITHUB_WORKSPACE/wiki | |
FILE="Release-Notes.md" | |
echo ${{ github.event.release.tag_name }} | |
# Format the new release notes with a header | |
NEW_CONTENT="## ${{ github.event.release.tag_name }} - $(date +"%Y-%m-%d")\n\n$RELEASE_NOTES\n\n" | |
# If the file exists, append new notes at the top; otherwise, create it | |
if [ -f "$FILE" ]; then | |
echo -e "$NEW_CONTENT$(cat $FILE)" > "$FILE" | |
else | |
echo -e "$NEW_CONTENT" > "$FILE" | |
fi | |
env: | |
GH_TOKEN: ${{ github.token }} | |
- name: Commit and Push to Wiki | |
run: | | |
cd $GITHUB_WORKSPACE/wiki | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Update release notes for ${{ github.event.release.tag_name }}" | |
git push | |
env: | |
GH_TOKEN: ${{ github.token }} |