ines / course-starter-python

👩‍🏫🐍 Starter repo for building interactive Python courses
https://course-starter-python.netlify.com
MIT License
504 stars 118 forks source link

Github Action for building course to Github pages #23

Closed psychemedia closed 4 years ago

psychemedia commented 4 years ago

I made a start on trying to build a Github Action to try to build and push a course to Github Pages, but gatsby is completely new to me so I'm not sure where I'm going wrong, getting a GraphQLError: Cannot query field "allMarkdownRemark" on type "Query". error when I try to run it

# .github/workflows/build_and_publish_course.yml
name: "gatsby publisher"
on:
  push:
    branches:
      - master
jobs:
  builder:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v1
      with:
        node-version: '10.x'
    - run: |
        npm install
        npm install --global gatsby-cli
    - name: Use build branch context
      run: |
        sudo chown -R $(whoami):$(whoami) .
        git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
        git config --global user.name "$GITHUB_ACTOR"
        git checkout -b build
        git merge master
    - name: Build docs HTML
      run: |
        if [ ! -f .path_config_set ]; then
          echo "module.exports = { pathPrefix: \"/${GITHUB_REPOSITORY##*/}\"}" >> gatsby-config.js
          touch .path_config_set
        fi

        gatsby build --prefix-paths
        git add --all --force public
        git commit -a -m 'Push build branch'
        git push
    - name: Deploy HTML site to gh-pages
      uses: peaceiris/actions-gh-pages@v3
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
        publish_dir: ./public
ines commented 4 years ago

That's strange 🤔 Does it work when you run it locally? And when does that error happen? When you build the site, or when it's opened in the browser?

(Also, this course seems to deploy to GH pages, so maybe you can find a clue there? https://github.com/noamross/gams-in-r-course)

psychemedia commented 4 years ago

I see what I did.... I'd overwritten module.exports in gatsby-config.js rather than added to it. Also, I was messing up on the branches too... seems to work now (here).