A GitHub Action that keeps a target branch (default: main) in sync with release artifacts published on the release branch (default: release) after semantic-release. It either merges the changes or opens a pull request, depending on the input.
- Fetches
mainandreleasebranches - Optionally opens a PR from
releaseintomainwhenpr-needed: 'true' - Otherwise merges
releaseintomainand pushes the result - Skips PR creation if no changes exist
Example workflow:
name: Update main branchon:
push:
branches: [ release ]paths-ignore:
- 'CHANGELOG.md'permissions:
contents: writepull-requests: writejobs:
sync:
runs-on: ubuntu-lateststeps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0with:
fetch-depth: 0
- uses: knowledgepixels/sync-release-artifacts-action@3926beed487a1c183af52423344bf6ee36fd7b27 # v1.0.0with:
main-branch: mainrelease-branch: releasepr-needed: falsegit-user-name: github-actions[bot]git-user-email: github-actions[bot]@users.noreply.github.com| Name | Description | Required | Default |
|---|---|---|---|
main-branch | Branch to update (target). | No | main |
release-branch | Branch to merge from (source). | No | release |
pr-needed | If true, open a PR instead of pushing directly. Skips PR if no diff. | No | false |
git-user-name | User name for commits/merges. | No | github-actions[bot] |
git-user-email | Email for commits/merges. | No | github-actions[bot]@users.noreply.github.com |
- Ensure the workflow grants:
contents: write(required to push)pull-requests: write(required whenpr-needed: 'true')
- Use
actions/checkoutwithfetch-depth: 0(action expects a working repository). - If
mainis protected, provide a token or allow the Actions bot to push, or use the PR flow.
- Use a test workflow that prepares a
releasebranch and runs the action withpr-neededset totrueandfalse. - A matrix job can run both flows in one dispatch: prepare
releasewith a tiny change for thetruerun, keep it identical for thefalserun.
- The action does not resolve real merge conflicts.
- When
pr-needed: 'true'and there are no changes, PR creation is skipped with a clear log message. - Consider branch protection and required checks when using the PR flow.