From 82f55b790c2b05e2dc061aeade8248ad59ff30f2 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Thu, 24 Jun 2021 14:07:49 -0300 Subject: [PATCH] Sync branch with NYPL. (#5) --- .github/workflows/sync.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 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 00000000..c061ac2f --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,37 @@ +name: Sync branch with NYPL +on: + schedule: + - cron: '0 7 * * *' + + workflow_dispatch: + +jobs: + sync_with_nypl: + runs-on: ubuntu-latest + + env: + REMOTE_ORG: NYPL-Simplified + REMOTE_REPO: registry_admin + REMOTE_BRANCH: master + LOCAL_BRANCH: nypl/master + + steps: + - name: Checkout local branch + uses: actions/checkout@v2 + with: + ref: ${{ env.LOCAL_BRANCH }} + + - name: Fetch remote repo + id: fetch + run: | + git remote add upstream https://github.com/${{ env.REMOTE_ORG }}/${{ env.REMOTE_REPO }}.git + git fetch upstream ${{ env.REMOTE_BRANCH }} + echo "::set-output name=LOCAL_COMMIT::$(git rev-parse refs/heads/${{ env.LOCAL_BRANCH }})" + echo "::set-output name=REMOTE_COMMIT::$(git rev-parse refs/remotes/upstream/${{ env.REMOTE_BRANCH }})" + + - name: Sync + if: steps.fetch.outputs.LOCAL_COMMIT != steps.fetch.outputs.REMOTE_COMMIT + run: | + git pull --no-edit --ff-only upstream ${{ env.REMOTE_BRANCH }} + git push origin ${{ env.LOCAL_BRANCH }} +