From f87ed6e38879a99d18e63919a004dbf0eb9bd7af Mon Sep 17 00:00:00 2001 From: Alex Bates Date: Sun, 24 Mar 2024 04:37:10 +0000 Subject: [PATCH] ci: create sync workflow --- .github/workflows/sync.yml | 39 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/sync.yml diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000000..5babef81ef --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,39 @@ +# 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: pmret/papermario # If you forked dx, change this to star-haven/papermario-dx! + 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: Fetch upstream + run: git fetch https://github.com/${{ env.UPSTREAM }}.git ${UPSTREAM_BRANCH} + - name: Merge upstream + run: | + git checkout ${BASE_BRANCH} + git merge --no-ff --log FETCH_HEAD -m "Merge upstream changes" + - name: Push changes + run: git push origin ${BASE_BRANCH} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Create Pull Request + run: | + gh pr create --title "Sync with ${{ env.UPSTREAM }}" --body "Automated PR to keep this repository in sync with upstream. Beep boop." --base ${BASE_BRANCH} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} +