oauth-tutorial icon indicating copy to clipboard operation
oauth-tutorial copied to clipboard

CI with GH actions?

Open deven367 opened this issue 2 years ago • 17 comments

hey @hamelsmu, thanks for this great tutorial. I was thinking is there a way to use this same principle to deploy private nbdev docs? Also, use GH actions alongside so that it allows CI?

If possible, I'll try to help :)

deven367 avatar Feb 25 '23 18:02 deven367

Yes I think it's pretty straight forward, nbdev generates the static site in the same way quarto does with a _docs/ folder after you run nbdev_docs

So if you took this tutorial I think you have everything you need to make it happen! Let me know if you have any questions - we would love for someone to write a nbdev specific tutorial and wire it up with CI - do you want to take a crack at it? I can help if you get stuck!

cc: @jph00 @seem

hamelsmu avatar Feb 25 '23 20:02 hamelsmu

Sure, I will give it a try right now. I'll let you know if I get stuck somewhere.

deven367 avatar Feb 25 '23 20:02 deven367

@hamelsmu I think I'm done. The site is deployed successfully, but I get a 404 as it can't find the index.html

image

deven367 avatar Feb 25 '23 21:02 deven367

Here is the repo, https://github.com/deven367/nbdev-oauth Also, for the deployment to go through, I had to push the _docs folder to the master branch as well. I wanted the deployment to work off of the gh-pages branch, but that needs the render.yml, dockerfile and the email_list files on the gh-pages branch.

The current workflow has been set to create an orphan branch to publish the site. If we set force_orphan to false, I think the whole deployment could work through the gh-pages branch directly. image

deven367 avatar Feb 25 '23 21:02 deven367

@hamelsmu I think I'm done. The site is deployed successfully, but I get a 404 as it can't find the index.html

image

Hi Deven you are showing me a GitHub pages error, but that doesn't make any sense since you should be deploying your site through Render. Am I missing something ?

hamelsmu avatar Feb 25 '23 21:02 hamelsmu

Also if you deploy your site through a Render blueprint there is no need for GitHub Actions. It will monitor your repo for changes and rebuild.

hamelsmu avatar Feb 25 '23 21:02 hamelsmu

Apologies. I had put the incorrect url in the oauth app. It's working as expected now!!

deven367 avatar Feb 25 '23 21:02 deven367

Excellent! Do you mind writing a tutorial and/or do a quick video to show other people how to do the same? I think it might be really valuable!

hamelsmu avatar Feb 25 '23 21:02 hamelsmu

Sure, I can write a small walkthrough. As an additional feature, should I try to get this to work through the gh-pages branch?

deven367 avatar Feb 25 '23 21:02 deven367

If you are up to it I think it could make for a good tutorial on the nbdev docs or blog itself. @jph00 WDYT?

hamelsmu avatar Feb 25 '23 21:02 hamelsmu

I think the gh-pages branch would be better, as in the current approach we also need to push the _docs with each change, unless we could do that directly in docker?

deven367 avatar Feb 25 '23 21:02 deven367

Yeah there are different approaches:

  • build the site in Docker too (you would have to have all the nbdev dependencies). This might be the cleanest.
  • render.yaml allows you to target a different branch https://render.com/docs/blueprint-spec, if you want to do the branch approach, but then you need GH Actions

hamelsmu avatar Feb 25 '23 21:02 hamelsmu

Deven this file might help you if you are trying to build the dependencies https://github.com/fastai/workflows/blob/master/quarto-ghp/action.yml

hamelsmu avatar Feb 25 '23 22:02 hamelsmu

Yeah, I think I figured it out. With minimal change, it is working directly with the gh-pages branch. The new workflow requires minimal change, you just need to push the 3 files to the gh-pages braches and modify the workflow slightly.

Here is my modified workflow

name: Deploy to GitHub Pages

permissions:
  contents: write
  pages: write

on:
  push:
    branches: [ "main", "master" ]
  workflow_dispatch:
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: deven367/workflows/quarto-ghp@master
        with:
          orphan: false
          keep_files: true

deven367 avatar Feb 25 '23 22:02 deven367

Sounds good!

hamelsmu avatar Feb 25 '23 22:02 hamelsmu

I'll write a nb for this titled nbdev with Oauth, do you want me include anything else?

deven367 avatar Feb 25 '23 22:02 deven367

My only suggestion if you are going to do a PR against nbdev with a new tutorial is to make it as generalizable as possible so that people are aware they don't have to use Render. You can accomplish this by linking to this OAuth tutorial if you like where I mention different alternatives (but feel free to accomplish this another way if you have a good idea)

Thanks in advance for your help!

hamelsmu avatar Feb 25 '23 23:02 hamelsmu