From b6cdf39c579c22e78d0a7ba25450bd060ed38110 Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Fri, 13 Aug 2021 13:39:41 +0200 Subject: [PATCH] Create sync-staging.yml --- .github/workflows/sync-staging.yml | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/sync-staging.yml diff --git a/.github/workflows/sync-staging.yml b/.github/workflows/sync-staging.yml new file mode 100644 index 0000000..18684a1 --- /dev/null +++ b/.github/workflows/sync-staging.yml @@ -0,0 +1,32 @@ +name: Sync staging from master + +on: + push: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Syncing staging branch + if: github.ref == 'refs/heads/master' && success() + run: | + echo "Syncing staging branch" + git remote add github "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY.git" + git remote -v + git fetch github + git checkout master + echo "Pulling master" + git pull github master + echo "Deleting staging branch" + git show-ref --verify --quiet "refs/heads/staging" && git branch -D staging + echo "Checking out new staging branch" + git checkout -b staging + echo "Force pushing new staging" + git push -f github staging + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + GITHUB_USER: $GITHUB_ACTOR