From 2ee08ed77d54c39c514accad420fae542d592dbe Mon Sep 17 00:00:00 2001 From: Niklas Fondberg Date: Thu, 27 Feb 2020 13:43:54 +0100 Subject: [PATCH] Add github sync action To sync staging branch with master on master commits --- .github/workflows/main.yml | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e055340 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,32 @@ +name: CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Run a one-line script + run: echo Running Github workflow + - 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.GITHUB_PAT }} + GITHUB_USER: $GITHUB_ACTOR