quarto-dev / quarto-actions

GNU General Public License v2.0
228 stars 53 forks source link

GH Pages error: No previous publishes available to re-publish #22

Open trangdata opened 2 years ago

trangdata commented 2 years ago

Hi, thanks for the neat repo! 💯 🚀

I have a very basic site created with Quarto (private repo) that I'm trying to set GH Actions for automatic deployment on GH Pages. The repo doesn't yet have a gh-pages branch, and I followed the exact step here but am encountering this peculiar error:

ERROR: No previous publishes available to re-publish (previous publish required with --no-prompt)

Any idea why this is? Thanks a bunch!

ghpages-error
trangdata commented 2 years ago

My workaround was to change the Deploy step from

      - name: Publish to GitHub Pages (and render)
        uses: quarto-dev/quarto-actions/publish@v2
        with:
          to: gh-pages
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 

to

      - name: Deploy
        if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && !github.event.repository.fork
        uses: peaceiris/actions-gh-pages@v3
        with:
          publish_dir: build
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: gh-pages
          cname: abc.net

and this is working for me now.

mcanouil commented 2 years ago

The action does not init/create the gh-pages when it does not exist thus leading to the error. GitHub-cli or GitHub Actions could be added to init the branch first similarly to what is done in pkgdown/usethis (see https://github.com/r-lib/usethis/blob/b0318bf7cadd25797ae97301893923933207c5ca/R/github-pages.R#L118-L166).

cscheid commented 2 years ago

Sorry this tripped you up. We have a note about this in the example documentation:

run quarto publish gh-pages locally, once Quarto needs to configure the repository for publishing through GitHub Actions. To do this, run quarto publish gh-pages locally once.

but we should make it clearer why that is. After you run publish locally once, the github actions will work.

trangdata commented 2 years ago

@cscheid ah okay thank you for the note! Please feel free to close the issue.