Sync upstream #52
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
# This workflow tries to keep this repo in sync with upstream commits. | |
# It creates a pull request merging upstream into this repo. | |
# If the tests pass then the PR is automatically merged by GitHub. | |
name: Sync upstream | |
env: | |
UPSTREAM_BRANCH: main | |
BASE_BRANCH: main | |
on: | |
workflow_dispatch: | |
repository_dispatch: | |
types: | |
- webhook # 'push' event on upstream | |
schedule: | |
- cron: 0 0 * * * | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.BASE_BRANCH }} | |
- name: Determine upstream | |
run: | | |
if [[ "${{ github.repository }}" == "bates64/papermario-dx" ]]; then | |
echo "UPSTREAM=pmret/papermario" >> $GITHUB_ENV | |
else | |
echo "UPSTREAM=bates64/papermario-dx" >> $GITHUB_ENV | |
fi | |
- name: Fetch upstream | |
run: git fetch https://github.com/$UPSTREAM.git $UPSTREAM_BRANCH | |
- name: Set git user | |
# https://github.com/orgs/community/discussions/26560 | |
run: | | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "github-actions[bot]" | |
- name: Merge upstream | |
run: | | |
git checkout ${BASE_BRANCH} | |
git merge --no-ff --log FETCH_HEAD -m "Merge upstream changes" | |
- name: Create Pull Request | |
run: | | |
gh pr create --title "Sync with $UPSTREAM" --body "Automated PR to keep this repository in sync with upstream. Beep boop." --base ${BASE_BRANCH} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |