Add github sync action

To sync staging branch with master on master commits
This commit is contained in:
Niklas Fondberg
2020-02-27 13:43:54 +01:00
committed by GitHub
parent b08aa76acc
commit 2ee08ed77d
+32
View File
@@ -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