royal-statistical-society / datavisguide

Introductory guide to the art and science of data visualisation. Insights, advice, and examples (with code) to make data outputs more readable, accessible, and impactful.
https://royal-statistical-society.github.io/datavisguide/
Other
129 stars 20 forks source link

Build_deploy_site action #20

Open brtarran opened 1 year ago

brtarran commented 1 year ago

I'm trying to setup a second GH action so that after a push to main triggers the PDF build, the resulting commit message 'Render PDF' then triggers another workflow that renders the site to GH pages automatically. I looked online for guidance and tried the suggestions I found, but none of them work as intended.

Any suggestions/fixes welcome!

brtarran commented 1 year ago

This has mostly been achieved with the workflow in 6302ddc, save one issue.

After the render action, the new PDF is committed to main branch, but the build-deploy action does not then carry the updated PDF across to gh-pages branch.

@nrennie, how do we update the Render PDF commit instructions so that the file is committed to gh-pages instead of main (or we could commit to both, if possible)?

      - name: Commit files
        run: |
          git config --local user.email "actions@github.com"
          git config --local user.name "GitHub Actions"
          git add RSS-data-vis-guide.pdf
          git commit -m "Render PDF"
          git push

Update: The PDF is deployed, but it seems to always be one version behind. Not sure, then, if the solution is to commit to gh-pages, as perhaps the gh-pages version will be replaced by the older main version once the build-deploy action runs.

I'm not sure what is wrong with the action to make it so that the build-deploy job doesn't take account of the Render PDF commit from the previous job.

nrennie commented 1 year ago

Checking out the gh-pages branch before committing might be enough? e.g.

- name: Commit files
        run: |
          git config --local user.email "actions@github.com"
          git config --local user.name "GitHub Actions"
          git checkout gh-pages
          git add RSS-data-vis-guide.pdf
          git commit -m "Render PDF"
          git push
brtarran commented 1 year ago

Thanks for the suggestion, but it didn't work unfortunately. I keep getting the following error:

error: pathspec 'gh-pages' did not match any file(s) known to git

I tried (in a0017ab) to add the file to main and then add the file to the gh-pages branch using the following:

          git checkout gh-pages
          git checkout main RSS-data-vis-guide.pdf
          git commit -m "Render PDF"
          git push

It worked locally in the command line, but the GH action doesn't seem to like it.