Yet another action to keep your fork in sync with upstream.
Why? Most I could find would either:
--hard-reset
main branch with the upstream one (hey, it's a fork...!)- merge upstream immediately (or try to) lacking conflict resolution
This one just fetches upstream branch (default to main
) and pushes it to your fork as a new branch.
It doesn't try to merge.
It doesn't replace anything.
It will open a pull-request and Github UI will allow you to merge it and resolve (simple) conflicts.
To open the pull request, standard action GITHUB_TOKEN
is not enough, so personal access token with enough access needs to be provided.
As it inspects target branch history (in your fork) to check if there is anything new in upstream, it requires a full checkout: that means full-depth: 0
with actions/checkout
See action.yml
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-branch: develop
This example will check https://github.com/surface-security/surface main
branch daily. Also allows for manual/API triggered checks (workflow_dispatch
).
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
Looking for edge changes, keep fork in sync with upstream develop
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-branch: develop
upstream-tag
matches entire tag name, so v1.2.3-dev1
is excluded, even if it is the latest.
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-tag: 'v1\.\d+\.\d+'
upstream-tag
matches entire tag name, so v1.2.3-dev1
is excluded, even if it is the latest.
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-tag: 'v1\..*'
reviewers
and team_reviewers
are optional parameters that expect a comma separated string with usernames or teams respectively.
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-tag: 'v1\.\d+\.\d+'
reviewers: person1,person2
team_reviewers: team1,team2
Upstream to PR outputs the API URL as the pull-request-url
variable for the created Pull Request so you can use it in other steps.
name: upstream to PR
on:
schedule:
- cron: "0 12 * * *"
workflow_dispatch:
inputs: {}
jobs:
autoupdate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PAT }}
- uses: fopina/upstream-to-pr@v1
id: auto-pr
with:
token: ${{ secrets.PAT }}
upstream-repository: https://github.com/surface-security/surface
upstream-tag: 'v1\.\d+\.\d+'
reviewers: person1,person2
team_reviewers: team1,team2
- name: Display output
run: |
echo "Pull Request API URL: ${{ steps.auto-pr.outputs.pull-request-url }}"