plentico / plenti

Static Site Generator with Go backend and Svelte frontend
https://plenti.co
Apache License 2.0
1.01k stars 49 forks source link

Netlify backend for CMS #262

Open jimafisk opened 1 year ago

jimafisk commented 1 year ago

We currently have a GitLab backend for the CMS and would like to add a GitHub backend as well, but that is held up until they support PKCE. Another popular option for backend provider who be Netlify since they have their own Git and OAuth.

Netlify can be used as an OAuth provider. It sounds like they support Implicit Grant, but not sure about PKCE - we'd want to verify this before attempting to implement.

Another strange thing is Netlify's build process. You can't actually specify a custom image as shown here and discussed here. We'd have to get a PR accepted to their build image, similar to the Hugo setup in order to build Plenti sites in their CI (otherwise you have to build elsewhere and copy the files over). Seems like a very strange approach, their Hugo build version is set manually and already many versions behind the current release.

jamestagal commented 9 months ago

Hi Jim,

I just wanted to follow up on this post and see whether it is worth looking further into this. I was interest in using Netlify only because they manage a nice easy solution for web forms. And I think you can even forward them on for clients.

I had a quick look in Netlify's docs https://docs.netlify.com/security/secure-access-to-sites/oauth-provider-tokens/ but I didn't see any reference to PKCE auth and then there is the other complication you mentioned about their build process.

I guess this is not a very good reason to pursue Netlify as a backend for Plenti's CMS but I am just having issues implementing a simple and robust web form submission solution. 😞

Best regards, Ben

jimafisk commented 9 months ago

Hi @jamestagal,

You should be able to use Netlify as your website host if you prefer that to GitLab Pages, you'd just still need to use GitLab for your CI/CD builds and OAuth. This video has some basic instructions on how to set that up: https://youtu.be/TmWIeUOsERY?si=wWjjoYzvCRokCgIG&t=574

Things to note:

jamestagal commented 9 months ago

Thanks Jim.

I will take a look and see if I can set it up.

BTW. It wouldn't be that I prefer one over the other it's just a case of getting a web form solution that just works. :) I have been trying to get a Google Form which is connected to the site and to the clients Gmail to work and I have had mixed results and nothing that is working consistently.

Thanks for posting here Jim. Appreciate it. Regards,

Ben

jamestagal commented 9 months ago

Hi @jimafisk I have a couple of follow up questions:

  1. Would the following be ok for a possible buildnetlify-deploy.yml file?
name: netlify deployment

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Build
        uses: docker://plentico/plenti:latest
        with:
          entrypoint: /plenti
          args: build  --output=build

      - name: Setup Node
        uses: actions/setup-node@v2-beta
        with:
          node-version: '16'

      - name: Deploy to Netlify
        run: |
          npm install netlify-cli -g
          netlify deploy --prod --dir deploy/public --site=${{ secrets.NETLIFY_SITE_ID }} --auth=${{ secrets.NETLIFY_AUTH_TOKEN }} --timeout=600 --message "Deployed on $(date)"
  1. So clarify the Actions for GitLab, would I just generate an access token and Site ID in Netlify and save them in a .gitlab-ci.yml file in GitLab? I'm not completely sure of how to format it correctly.
  2. Another question would be would the code sit in Netlify and be connected to the auth CD/CI in GitLab?

Thanks Ben

jimafisk commented 9 months ago

Would the following be ok for a possible buildnetlify-deploy.yml file?

I'm honestly not sure, the best bet would be to try running it and seeing if there any errors

So clarify the Actions for GitLab, would I just generate an access token and Site ID in Netlify and save them in a .gitlab-ci.yml file in GitLab? I'm not completely sure of how to format it correctly.

Yeah exactly, the video I referenced above should show where to do that

Another question would be would the code sit in Netlify and be connected to the auth CD/CI in GitLab?

The code would live in the GitLab repo and the OAuth app would be in GitLab as well. Only the compiled static site would get sent to Netlify.

jimafisk commented 6 months ago

Just wanted to drop @jamestagal's new video about deploying Plenti to Netlify: https://youtu.be/MQrXo1a0PtU?si=5P_gilK-wrCDYUwx <-- This is the best resource for how to do this