just use gh #8
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: Auto Changelog PR | |
on: | |
release: | |
types: [published, created] | |
workflow_dispatch: # Add this line to allow manual triggering | |
push: | |
branches: | |
- eli/automated-changelog | |
jobs: | |
changelog: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the Beta9 repo | |
uses: actions/checkout@v3 | |
- name: Fetch the latest release data | |
id: release | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const isRelease = context.eventName === 'release'; | |
if (isRelease) { | |
const release = context.payload.release; | |
core.setOutput('name', release.name.replace(/\s+/g, '-')); | |
core.setOutput('body', release.body); | |
core.setOutput('created_at', release.created_at); | |
} else { | |
const name = 'test v1.0.0'; | |
core.setOutput('name', name.replace(/\s+/g, '-')); | |
core.setOutput('body', 'This is a mock release body for testing purposes.'); | |
core.setOutput('created_at', new Date().toISOString()); | |
} | |
- name: Checkout beam-docs repo | |
uses: actions/checkout@v3 | |
with: | |
repository: slai-labs/beam-docs | |
path: beam-docs | |
token: ${{ secrets.BEAM_DOCS_PAT }} | |
- name: Create new release file in beam-docs | |
run: | | |
cd beam-docs/v2/releases | |
RELEASE_DATE=$(date -I) | |
FILENAME="${RELEASE_DATE}.md" | |
echo "# Release: ${{ steps.release.outputs.name }}" > $FILENAME | |
echo "" >> $FILENAME | |
echo "Release date: ${{ steps.release.outputs.created_at }}" >> $FILENAME | |
echo "" >> $FILENAME | |
echo "## Changelog" >> $FILENAME | |
echo "${{ steps.release.outputs.body }}" >> $FILENAME | |
- name: Commit and push changes | |
run: | | |
cd beam-docs | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
git checkout -b autochangelog/${{ steps.release.outputs.name }} | |
git add . | |
git commit -m "Add changelog for ${{ steps.release.outputs.name }}" | |
git push -u origin autochangelog/${{ steps.release.outputs.name }} | |
- name: Create pull request | |
run: | | |
cd beam-docs | |
gh pr create --title "Changelog for ${{ steps.release.outputs.name }}" --body "This PR adds the changelog for ${{ steps.release.outputs.name }}." --base main --head autochangelog/${{ steps.release.outputs.name }} |