orchid00 / actions_sandbox

https://ropenscilabs.github.io/actions_sandbox/
Other
17 stars 6 forks source link

Changes in Cecilapp/GitHub-Pages-deploy causing deployment failure #39

Closed bchwtz closed 3 years ago

bchwtz commented 3 years ago

Thank you for creating this guide. During the holidays the authentication in the Cecilapp/GitHub-Pages-deploy workflow changed and now your examples cause errors, because they still refer to the master branch.

GitHub Pages deploy v3 now use the secrets.GITHUB_TOKEN instead of a personal access token (PAT), and inputs parameters instead of environment variables.

A quick fix is replacing all master branch references with a new one referring to v2 (Cecilapp/GitHub-Pages-deploy@v2). Here is what worked for me with bookdown. However in the long rung it may make sense to follow the transition and use secrets instead of the PAT as well.

on:
  push:
     branches:
       - master

name: renderbook

jobs:
  bookdown:
    name: Render-Book
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v1
      - uses: r-lib/actions/setup-r@v1
      - uses: r-lib/actions/setup-pandoc@v1
      - name: Install rmarkdown
        run: Rscript -e 'install.packages(c("rmarkdown","bookdown"))'
      - name: Render Book
        run: Rscript -e 'bookdown::render_book("index.Rmd")'
      - uses: actions/upload-artifact@v1
        with:
          name: _book
          path: _book/

# Need to first create an empty gh-pages branch
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html
# and also add secrets for a GH_PAT and EMAIL to the repository
# gh-action from Cecilapp/GitHub-Pages-deploy
  checkout-and-deploy:
   runs-on: ubuntu-latest
   needs: bookdown
   steps:
     - name: Checkout
       uses: actions/checkout@master
     - name: Download artifact
       uses: actions/download-artifact@v1.0.0
       with:
         # Artifact name
         name: _book # optional
         # Destination path
         path: _book # optional
     - name: Deploy to GitHub Pages
       uses: Cecilapp/GitHub-Pages-deploy@v2
       env:
          EMAIL: ${{ secrets.EMAIL }}               # must be a verified email
          GH_TOKEN: ${{ secrets.GH_PAT }} # https://github.com/settings/tokens
          BUILD_DIR: _book/                     # "_site/" by default
lachlandeer commented 3 years ago

Can be solved as follows:

# Need to first create an empty gh-pages branch
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html
# and also add secrets for a GH_PAT and EMAIL to the repository
# gh-action from Cecilapp/GitHub-Pages-deploy
  checkout-and-deploy:
   runs-on: ubuntu-latest
   needs: bookdown
   steps:
     - name: Checkout
       uses: actions/checkout@master
     - name: Download artifact
       uses: actions/download-artifact@v1.0.0
       with:
         # Artifact name
         name: _book # optional
         # Destination path
         path: _book # optional
     - name: Deploy to GitHub Pages
       uses: Cecilapp/GitHub-Pages-deploy@v3
       with:
          build_dir: _book/
          email: ${{ secrets.EMAIL }}
       env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
orchid00 commented 3 years ago

Thanks @stephan-koenig and @lachlandeer this PR https://github.com/orchid00/actions_sandbox/pull/40 addresses the changes

orchid00 commented 3 years ago

just realised I still need to change the examples /actions_sandbox/websites-using-pkgdown-bookdown-and-blogdown.html#deploy-bookdown

orchid00 commented 3 years ago

So guys I fixed the texts and the examples you can have a look, if anything needs to be fixed please ping me.

Could you also please, have a look at issue https://github.com/orchid00/actions_sandbox/issues/41 I feel you might be able to help enlightening me.