From aec352819baf86f1e562bb2e6acefc4448c2a74c Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Tue, 2 Jul 2024 15:17:46 +0200 Subject: [PATCH 1/3] Use detect-package-manager to run tinacms build Co-authored-by: dhayab <154633+dhayab@users.noreply.github.com> --- .../deployment-options/github-pages.md | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/content/docs/tina-cloud/deployment-options/github-pages.md b/content/docs/tina-cloud/deployment-options/github-pages.md index 5a9012a326..e2f89165f1 100644 --- a/content/docs/tina-cloud/deployment-options/github-pages.md +++ b/content/docs/tina-cloud/deployment-options/github-pages.md @@ -20,27 +20,15 @@ By clicking "Configure" on the action it's created for us, we can then tweak the Add the following step **before** your site's build step: -If you are using npm as your package name, you can use the following: ```yml - name: Build TinaCMS env: TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} TINA_TOKEN: ${{ secrets.TINA_TOKEN }} - run: npx tinacms build -``` - -or if you are using yarn: - -```yml -- name: Build TinaCMS - env: - TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} - TINA_TOKEN: ${{ secrets.TINA_TOKEN }} - run: yarn build - # This assumes that your "build" script in your - # package.json is "tinacms build" -``` + run: ${{ steps.detect-package-manager.outputs.runner }} tinacms build +``` +NB: If you're using a package manager other than `npm` or `yarn`, you must replace `${{ steps.detect-package-manager.outputs.runner }}` with your own. Your GitHub Action will look something like: From f11c3d2995fd360ae466de0d0e7e20e586378a79 Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Tue, 2 Jul 2024 15:24:10 +0200 Subject: [PATCH 2/3] Homogenize variable environments with other examples from documentation Co-authored-by: dhayab <154633+dhayab@users.noreply.github.com> --- content/docs/tina-cloud/deployment-options/github-pages.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/docs/tina-cloud/deployment-options/github-pages.md b/content/docs/tina-cloud/deployment-options/github-pages.md index e2f89165f1..088b060d75 100644 --- a/content/docs/tina-cloud/deployment-options/github-pages.md +++ b/content/docs/tina-cloud/deployment-options/github-pages.md @@ -24,7 +24,7 @@ Add the following step **before** your site's build step: ```yml - name: Build TinaCMS env: - TINA_PUBLIC_CLIENT_ID: ${{ secrets.TINA_PUBLIC_CLIENT_ID }} + NEXT_PUBLIC_TINA_CLIENT_ID: ${{ secrets.NEXT_PUBLIC_TINA_CLIENT_ID }} TINA_TOKEN: ${{ secrets.TINA_TOKEN }} run: ${{ steps.detect-package-manager.outputs.runner }} tinacms build ``` @@ -78,4 +78,4 @@ Check to make sure that the build command is running and not failing ## Environment variables -Assuming that your Tina `clientID` and `token` are setup as environment variables, you will need to add those to the GitHub Secrets for your project. The secrets we used in the code snippet above were `TINA_PUBLIC_CLIENT_ID` & `TINA_TOKEN` +Assuming that your Tina `clientID` and `token` are setup as environment variables, you will need to add those to the GitHub Secrets for your project. The secrets we used in the code snippet above were `NEXT_PUBLIC_TINA_CLIENT_ID` & `TINA_TOKEN` From 13358d01937bf0df8c6ad7cc01d37323b8616021 Mon Sep 17 00:00:00 2001 From: Florian Sommariva Date: Tue, 2 Jul 2024 16:00:04 +0200 Subject: [PATCH 3/3] Add rewrites configuration common issue for GH pages doc Co-authored-by: dhayab <154633+dhayab@users.noreply.github.com> --- .../deployment-options/github-pages.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/content/docs/tina-cloud/deployment-options/github-pages.md b/content/docs/tina-cloud/deployment-options/github-pages.md index 088b060d75..e60e806119 100644 --- a/content/docs/tina-cloud/deployment-options/github-pages.md +++ b/content/docs/tina-cloud/deployment-options/github-pages.md @@ -76,6 +76,40 @@ Check to make sure that the build command is running and not failing > Note: If you are using [the github pages setup from hugo](https://gohugo.io/hosting-and-deployment/hosting-on-github/) you will need to make sure that a `package-lock.json` exists in the root of your repo. +### Common Issue: Github actions fail due to `rewrites` error + +When running the CI, you get this message + +```shell + > Build error occurred +Error: Specified "rewrites" cannot be used with "output: export". See more info here: https://nextjs.org/docs/messages/export-no-custom-routes +``` + +That's because you have a `rewrites` configuration in your `next.config.js`, like the following (from [Tina Starter](https://github.com/tinacms/tina-cloud-starter/blob/main/next.config.js)): + +```js +async rewrites() { + return [ + { + source: "/", + destination: "/home", + }, + { + source: "/admin", + destination: "/admin/index.html", + }, + ]; +}, +``` + +You need to remove them for this to work. +A solution to get the right redirection for the home page is to add these lines after the build step in `nextjs.yml`. + +```shell + - name: Rename home.html to index.html + run: mv ./out/home.html ./out/index.html +``` + ## Environment variables Assuming that your Tina `clientID` and `token` are setup as environment variables, you will need to add those to the GitHub Secrets for your project. The secrets we used in the code snippet above were `NEXT_PUBLIC_TINA_CLIENT_ID` & `TINA_TOKEN`