This repository contains a GitHub Actions workflow that automatically updates the changelog in the mock-docs-portal repository whenever the CHANGELOG.md file is updated in this repository.
- Trigger: When a commit is pushed to the
mainbranch that modifiesCHANGELOG.md - Action: The workflow automatically:
- Checks out both repositories
- Parses the latest version from the SDK changelog
- Updates the release notes in the docs portal while maintaining MDX formatting
- Creates a pull request with the changes
- Sends a Slack notification for review
You need to set up the following secrets in your SDK repository (mock-sdk):
DOCS_PORTAL_TOKEN: A GitHub Personal Access Token with permissions to:- Read from the SDK repo
- Write to the docs portal repo
- Create pull requests
SLACK_WEBHOOK_URL: A Slack webhook URL for notifications (optional but recommended)
- Go to GitHub Settings > Developer settings > Personal access tokens
- Generate a new token with the following scopes:
repo(full control of private repositories)workflow(if using GitHub Actions)
- Copy the token and add it as a secret in your SDK repo:
- Go to your repo → Settings → Secrets and variables → Actions
- Click "New repository secret"
- Name:
DOCS_PORTAL_TOKEN - Value: paste your token
The workflow needs to be able to create pull requests in the docs portal repository. Ensure your repository has the following settings:
- Go to Settings → Actions → General
- Under "Workflow permissions", select "Read and write permissions"
- Check "Allow GitHub Actions to create and approve pull requests"
Important: The DOCS_PORTAL_TOKEN must have write access to the docs portal repository to create pull requests.
.github/workflows/update-docs-changelog.yml- Main workflow fileupdate-release-notes.js- Node.js script for parsing and updating changelogpackage.json- Dependencies and scripts
- Make a change to
CHANGELOG.mdin this repository - Commit and push to the
mainbranch - Check the Actions tab to see the workflow running
- Check the docs portal repository for the new pull request
- Check your Slack channel for the notification (if configured)
You can test the changelog parsing script locally:
# Install dependencies
npm install
# Run the update script
npm run update
# Or run directly
node update-release-notes.jsNote: When testing locally, the script will read from ./CHANGELOG.md in the current directory and update ./release-notes.md. In the GitHub Actions workflow, it will use the path ../sdk/CHANGELOG.md to read from the checked-out SDK repository.
To change which repository receives the updates, modify the workflow file:
- name: Checkout docs portal repo
uses: actions/checkout@v4
with:
repository: your-username/your-repo-name
token: ${{ secrets.DOCS_PORTAL_TOKEN }}
path: ./docs-portalNote: The target repository must be accessible with the provided token, and the token must have write permissions.
To modify which files are processed, update the script variables:
const SDK_CHANGELOG_PATH =
process.env.SDK_CHANGELOG_PATH || "../sdk/CHANGELOG.md";
const RELEASE_NOTES_PATH = "./your-file-name.md";To change when the workflow runs, update the on section:
on:
push:
branches:
- main
- develop # Add more branches
paths:
- "CHANGELOG.md"
- "docs/**" # Add more paths- Permission Denied: Ensure your token has the correct permissions
- Workflow Not Triggering: Check that the file path in
pathsmatches exactly - Script Errors: Verify Node.js version compatibility (requires Node 18+)
Add debug logging to the workflow:
- name: Debug Info
run: |
echo "Current directory: $(pwd)"
echo "SDK changelog path: ${{ env.SDK_CHANGELOG_PATH }}"
ls -la- The
DOCS_PORTAL_TOKENshould have minimal required permissions (only what's needed for the docs portal repo) - Consider using GitHub Apps instead of Personal Access Tokens for production
- Regularly rotate your tokens
- Review workflow permissions carefully
- The token will have access to create pull requests in the docs portal repository
Feel free to submit issues and enhancement requests!
add a change here to test