Hugo + Bitbucket Pipelines + Github Pages

Hi all

Just recently picked up Hugo and I’m currently working on setting up continuous integration and through Bitbucket Pipelines with continuous deployment to Github Pages.
I’ve zeroed in on this setup because it’s free and suports custom domain, so good for learning but also for very small/non-profit use cases.

I’ve had a look at these resources Host on Bitbucket, Hugo website with Bitbucket Pipelines and Continuous Deployment for Jekyll using Bitbucket Pipeline to deploy in Github to:

  1. Creating a Hugo environment
  2. Generate site
  3. Deploy site

And I now have the current bitbucket-pipelines.yml:

    - step:
          - wget
          - dpkg -i hugo*.deb
          - git clone https://$<gituser>/<reponame>.git public
          - rm -r public/*
          - hugo -D
          - cd public
          - git config --global "<my email>"
          - git config --global "<my name>"
          - git add --all
          - git commit -m "update from pipelines"
          - git push origin

It’s all working, but I feel the deployment part can be improved.
Currently I’m doing a git clone before I replace the content and do a git push. Is there a way to not to clone first to avoid sending a lot of assets around?

Also, I’m using Github - Personal access tokens
I would prefer using Github - Deploy keys, as that is per repo access.

Thanks for any help and hope this also can be of use for someone else trying to achieve a similar setup.

P.s. Thanks to all of you maintaining and creating Hugo, both software and community is working great! D.s.