From 2fd586fdbebfd80e1e52d3aa74bcbd32ce3739ff Mon Sep 17 00:00:00 2001 From: Julien Duchesne Date: Mon, 5 Dec 2022 20:54:33 -0500 Subject: [PATCH] Deploy website to Github Pages This gets rid of netlify which we don't really need and is blocking PRs like https://github.com/grafana/tanka/pull/783 This contains two different parts: - A step that deploys to a preview for PRs - A step that deploys on a push to main --- .github/workflows/publish-page.yml | 45 ++++++++++++++++++++++++++++++ docs/gatsby-config.js | 1 + docs/package.json | 4 +-- netlify.toml | 5 ---- 4 files changed, 48 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/publish-page.yml delete mode 100644 netlify.toml diff --git a/.github/workflows/publish-page.yml b/.github/workflows/publish-page.yml new file mode 100644 index 000000000..08e73f5d1 --- /dev/null +++ b/.github/workflows/publish-page.yml @@ -0,0 +1,45 @@ +# .github/workflows/preview.yml +name: Deploy Github Pages + +on: + push: + branches: + - main + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +concurrency: ci-${{ github.ref }} + +jobs: + publish: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install and Build + working-directory: docs + env: + # Main: https://tanka.dev/ + # PRs: https://grafana.github.io/tanka/pr-preview/pr-{number}/ + PATH_PREFIX: "${{ github.event_name == 'pull_request' && format('/tanka/pr-preview/pr-{0}', github.event.number) || '' }}" + run: | + yarn install + yarn build + + - name: Deploy main + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@v4 + with: + clean-exclude: pr-preview/ + folder: ./docs/public/ + + - name: Deploy preview + if: github.event_name == 'pull_request' + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./docs/public/ \ No newline at end of file diff --git a/docs/gatsby-config.js b/docs/gatsby-config.js index 5debb7f74..300a21ed4 100644 --- a/docs/gatsby-config.js +++ b/docs/gatsby-config.js @@ -1,6 +1,7 @@ const path = require("path") module.exports = { + pathPrefix: process.env.PATH_PREFIX || "", siteMetadata: { title: `Grafana Tanka`, description: `Flexible, reusable and concise configuration for Kubernetes`, diff --git a/docs/package.json b/docs/package.json index 21ef171c6..e364409b0 100644 --- a/docs/package.json +++ b/docs/package.json @@ -34,10 +34,10 @@ ], "license": "Apache v2", "scripts": { - "build": "gatsby build", + "build": "gatsby build --prefix-paths", "dev": "gatsby develop", "format": "prettier --write \"**/*.{js,jsx,json,md}\"", - "serve": "gatsby serve", + "serve": "gatsby serve --prefix-paths", "clean": "gatsby clean" } } diff --git a/netlify.toml b/netlify.toml deleted file mode 100644 index 96724b901..000000000 --- a/netlify.toml +++ /dev/null @@ -1,5 +0,0 @@ -[build] - base = "docs/" - publish = "docs/public" - command = "yarn build" -