From f2fbbfc6e8be3645dec89783bbcd53ddd322e5f0 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Thu, 21 Nov 2024 00:05:46 +0530 Subject: [PATCH 1/3] feat(.github): add github actions to deploy to gh-pages --- .../setup-pnpm-with-dependencies/action.yaml | 61 +++++++++++++++++++ .github/workflows/github-pages.yaml | 58 ++++++++++++++++++ vite.config.ts | 1 + 3 files changed, 120 insertions(+) create mode 100644 .github/actions/setup-pnpm-with-dependencies/action.yaml create mode 100644 .github/workflows/github-pages.yaml diff --git a/.github/actions/setup-pnpm-with-dependencies/action.yaml b/.github/actions/setup-pnpm-with-dependencies/action.yaml new file mode 100644 index 0000000..1e0c6fb --- /dev/null +++ b/.github/actions/setup-pnpm-with-dependencies/action.yaml @@ -0,0 +1,61 @@ +name: Setup PNPM with Yarn Dependencies +description: Reusable composition of setup-node, cache, and pnpm install actions +inputs: + nodejs-version: + description: 'Version of NodeJS to use (ex: 18.18.2)' + default: '18.18.2' + force-install: + description: When 'true', pnpm install will be executed regardless of a cache hit + required: false + default: 'false' + frozen-lockfile: + description: When false, pnpm install will use the --no-frozen-lockfile flag + required: false + default: 'true' +outputs: + cache-hit: + description: Whether or not there was a cache hit + value: ${{ steps.dependency-cache.outputs.cache-hit }} +runs: + using: composite + steps: + + - name: get Node version + id: node-version + shell: bash + run: | + voltaNodeVersion=$(cat package.json|jq -r ".volta.node") + if [[ $voltaNodeVersion == null ]]; then + voltaNodeVersion="${{ inputs.nodejs-version }}" + fi + voltaPnpmVersion=$(cat package.json|jq -r ".volta.pnpm") + if [[ $voltaPnpmVersion == null ]]; then + voltaPnpmVersion="8.10.5" + fi + + echo "node-version=${voltaNodeVersion}">> $GITHUB_OUTPUT + echo "pnpm-version=${voltaPnpmVersion}">> $GITHUB_OUTPUT + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: ${{ steps.node-version.outputs.node-version }} + + - name: Install PNPM + shell: bash + run: | + npm i -g pnpm@${{ steps.node-version.outputs.pnpm-version }} + pnpm --version + + + - name: Dependency Cache + id: dependency-cache + uses: actions/cache@v4 + with: + path: '**/node_modules' + key: pnpm-${{ steps.node-version.outputs.pnpm-version }}-${{ steps.node-version.outputs.node-version }}-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} + + - name: Install Dependencies + if: ${{ inputs.force-install == 'true' || steps.dependency-cache.outputs.cache-hit != 'true' }} + shell: bash + run: pnpm i${{ inputs.frozen-lockfile == 'false' && ' --no-frozen-lockfile' || '' }} diff --git a/.github/workflows/github-pages.yaml b/.github/workflows/github-pages.yaml new file mode 100644 index 0000000..622c443 --- /dev/null +++ b/.github/workflows/github-pages.yaml @@ -0,0 +1,58 @@ +name: Deploy Spec Editor to GitHub Pages + +on: + push: + branches: + - main + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: 'pages' + cancel-in-progress: false + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + timeout-minutes: 10 + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup PNPM with Dependencies + uses: ./.github/actions/setup-pnpm-with-dependencies/ + with: + force-install: true + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build Spec Editor + run: pnpm build + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload sandbox/dist directory + path: './dist' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/vite.config.ts b/vite.config.ts index c9fca93..286f63b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -6,6 +6,7 @@ import vueDevTools from 'vite-plugin-vue-devtools' // https://vite.dev/config/ export default defineConfig({ + base: '/spec-editor', plugins: [ vue(), vueDevTools(), From d9ffe47ed52fa1ae73835bbbdfeb996407a5a0e5 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Thu, 21 Nov 2024 15:05:24 +0530 Subject: [PATCH 2/3] feat(codeowners): add a default CODEOWNERS file --- .github/CODEOWNERS | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..69eb75c --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,18 @@ +# These owners will be the default owners for everything in +# the repo. They will be requested for review whenever someone +# opens a PR, unless a later match takes precedence. +* @ValeryG @vaibhavrajsingh2001 + +# Workflows & CI +/.github/ @adamdehaven @jillztom @ValeryG @vaibhavrajsingh2001 +/lefthook.yaml @adamdehaven @jillztom @ValeryG @vaibhavrajsingh2001 + +# Main library code +/src/ @Kong/team-core-ui + +# ================================================ +# Renovate Bot approvals +# Allow Kongponents BOT to approve dependency updates +# These rules MUST remain at the bottom as the last entry +package.json @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001 +pnpm-lock.yaml @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001 From f03946eba668b9d272c684e91f3bb518ace18503 Mon Sep 17 00:00:00 2001 From: Vaibhav Date: Thu, 21 Nov 2024 22:58:33 +0530 Subject: [PATCH 3/3] fix(codeowners): add leading slash --- .github/CODEOWNERS | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 69eb75c..af8b9e9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -14,5 +14,5 @@ # Renovate Bot approvals # Allow Kongponents BOT to approve dependency updates # These rules MUST remain at the bottom as the last entry -package.json @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001 -pnpm-lock.yaml @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001 +/package.json @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001 +/pnpm-lock.yaml @kongponents-bot @Kong/team-core-ui @ValeryG @vaibhavrajsingh2001