MyBlog/output from master branch to root of gh-pages branch

I have a static website which is generating an output folder to the MyBlog/output in the master branch. But I want output to be the source of my GH Pages, I am looking for a way to use output as the root of gh-pages branch.

That’s my deploy.yml

name: Deploy Site
on: 
  push:
    branches:
      - master

jobs:
  build:
    runs-on: windows-latest
    steps:
    - uses: actions/checkout@master
      with:
        submodules: recursive
    - uses: actions/setup-dotnet@v1
      with:
        dotnet-version: '3.1.100'
    - run: dotnet run --project "MyBlog" -- deploy
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    - run: git push

What should I do / add to my deploy.yml to do what I want, please.

Thanks in advance.

Assuming your dotnet run command doesn’t stage and commit anything, the push currently isn’t doing anything. If I further assume the build will overwrite anything that’s already in output/ the easiest thing might be to do something like this to get the current gh-pages data into output/ before running the build:

- uses: actions/checkout@v2
  with:
    ref: gh-pages
    path: output

And then after the build you can add, commit, and push the changes (based on the example in actions/checkout documentation):

- run: |
    git config user.name github-actions
    git config user.email github-actions@github.com
    git add .
    git commit -m "automatic build for gh-pages"
    git push
  working-directory: output

Note that this doesn’t clean out anything old that the build doesn’t overwrite, you’ll have to either refine the process a little to clean up, too, or do that manually.

1 Like

I don’t really understand.
How to make it overwrite the old content ?

1 Like

Nevermind, all work.
Thanks everybody

1 Like