title: GitHub Actions: Move branch to another branch
body: <p>So I'm working on a project where I have a number of Sass stylesheets, and I want to host it on GitHub Pages. I've pointed Pages to the <code>gh-pages</code> branch, and when I make a change I am trying to set up Actions to 'teleport' that branch to my freshly-pushed <code>main</code> source code branch, make a commit containing the generation of new CSS files from the Sass source code, and push that to the <code>gh-pages</code> branch for Pages to host. This way I know it has started from the latest version of the source, with no leftover generated files, and run a single deterministic compilation to create the CSS files I'm after.</p>
  <p>I've been able to set this up, but the only way I've been able to get it working is by deleting the <code>gh-pages</code> branch, checking out the <code>main</code> branch, recreating <code>gh-pages</code> and committing from there. The problem with this is that, when the <code>gh-pages</code> branch gets deleted, GitHub Pages stops tracking it and moves back to the <code>main</code> branch. Here's the workflow anyway, just for reference:</p>
  <pre class="lang-yaml prettyprint-override"><code>name: Compile Sass
  
  on:
    push:
      branches:
        - main
  
  jobs:
    build_css:
      runs-on: ubuntu-latest
  
      steps:
        - name: Checkout source Git branch
          uses: actions/checkout@v2
          with:
              ref: main
              fetch-depth: 10
              submodules: true
        
        - name: Delete gh-pages branch
          uses: dawidd6/action-delete-branch@v3
          with:
            github_token: ${{ secrets.GITHUB_TOKEN }}
            branches: gh-pages
        
        - name: Create fresh gh-pages branch
          uses: peterjgrainger/action-create-branch@v2.0.1
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          with:
            branch: 'gh-pages'
  
        - name: Checkout new gh-pages branch
          uses: actions/checkout@v2
          with:
              ref: gh-pages
              fetch-depth: 1
  
        - name: Compile CSS from SCSS files
          uses: gha-utilities/sass-build@v0.4.5
          with:
            source: styles/index.scss
            destination: styles/index.css
  
        - name: Add and commit changes to gh-pages branch
          run: |
            git config --local user.email 'action@github.com'
            git config --local user.name 'GitHub Action'
            git add styles/*
            git commit -m 'Compile website'
  
        - name: Push changes
          uses: ad-m/github-push-action@master
          with:
            github_token: ${{ secrets.GITHUB_TOKEN }}
            branch: gh-pages
  </code></pre>
  <p>Solutions I've tried using <code>git rebase</code> and <code>git reset</code> haven't worked for a range of reasons, and I've found that the former (using <code>git rebase --onto main gh-pages gh-pages</code>) works on my local machine but not in CI.</p>
  <p>I feel like this must be a reasonably normal thing to want to do, so are there any more widely-accepted methods that I've missed?</p>