on:
  push:
    branches: [develop]

name: Update standalone branch

env:
  STANDALONE_BRANCH_NAME: standalone

jobs:
  update:
    name: Update standalone branch
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Setup git
        run: |
            git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
            git config --global user.name "$GITHUB_ACTOR"
            git fetch
      - name: Create standalone version
        run: |
          bash tools/create_standalone.sh /tmp/nowide_standalone
          git checkout "$STANDALONE_BRANCH_NAME" -- || git checkout -b "$STANDALONE_BRANCH_NAME"
          git rm -r *
          mv /tmp/nowide_standalone/* .
          git add .
      - name: Commit and push
        run: |
          git commit -am "Include '${{github.event.head_commit.message}}'"
          remote_repo="https://${GITHUB_ACTOR}:${{secrets.GITHUB_TOKEN}}@github.com/${GITHUB_REPOSITORY}.git"
          git push "$remote_repo" HEAD:$STANDALONE_BRANCH_NAME
      