Files
Niklas FondbergandGitHub 2ee08ed77d Add github sync action
To sync staging branch with master on master commits
2020-02-27 13:43:54 +01:00

33 lines
962 B
YAML

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