A github action to automatically create PR from a fork to the upstream
steps:
- uses: uknowwhoim/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
AUTO_PR_SETTINGS: ${{ secrets.AUTO_PR_SETTINGS }}
Handling multiple settings for different forks is tricky. To allow each fork to have its unique configuration, usage of repository secrets is recommended.
To allow certain forks to disable this workflow, add a condition to the workflow file, which skips the step if a certain repository secret is not set.
In this example this step would only be executed if the repository has a secret ALLOW_AUTO_PR
and its truthy.
steps:
- uses: uknowwhoim/[email protected]
if: ${{ env.ALLOW }}
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
AUTO_PR_SETTINGS: ${{ secrets.AUTO_PR_SETTINGS }}
ALLOW: ${{ secrets.ALLOW_AUTO_PR }}
The authentication token of user creating the PR. This user must have write access to the fork. How to create a token?
This parameter must be passed to the environment and must be stored as a repository secret.
- uses: uknowwhoim/auto-pr-fork@main
env:
GITHUB_TOKEN: ${{ secrets.AUTH_TOKEN }}
To provide more flexibility for forks, all settings are stored as json in the environment. You can do this by creating a repository secret and storing the JSON string inside it. Load the secret into the environment variable AUTO_PR_SETTINGS
.
Don't escape the JSON string it must be stored like {"title": "A title"}
not "{\"title\":\"A title\"}"
The configurable settings are as follows
The branch of the fork you want to merge into upstream.
Default is main
The branch of the upstream, you want to to merge your fork into.
Default is main
Make the PRs created by this repo draft by default(Public repos only)
Default is false
The title of PRs created by this action.
Default is Catch up with <OWNER>/<REPO_NAME>
The description of PRs created by this action.
Create a pull request on push.
# Triggers on all branches
on: push
# Triggers on main branch push only
on:
push:
branches:
- main
Schedule a pull request in a period of time repeatedly. Visit crontab guru to generate cron syntax.
on:
schedule:
# At 00:00 on every 3rd day-of-month
- cron: '0 0 */3 * *'