Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/sandbox pr previews #1742

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
3aa995c
chore: enable pr previews
adamdehaven Sep 28, 2023
369373c
chore: tweak permissions
adamdehaven Sep 28, 2023
4e3fc7e
chore: settings and permissions
adamdehaven Sep 28, 2023
913a270
chore: settings and permissions
adamdehaven Sep 28, 2023
558ef9a
chore: settings and permissions
adamdehaven Sep 28, 2023
4a883e8
chore: settings and permissions
adamdehaven Sep 28, 2023
aed70c9
chore: add preview link
adamdehaven Sep 28, 2023
14509f5
chore: edit preview link
adamdehaven Sep 28, 2023
922cc2c
chore: add pr-preview ignore
adamdehaven Sep 28, 2023
a1a33ff
chore: fix link
adamdehaven Sep 28, 2023
c7ab7c3
chore: cancel in progress
adamdehaven Sep 28, 2023
201fac8
chore: rename group
adamdehaven Sep 28, 2023
79939b0
chore: format link
adamdehaven Sep 28, 2023
974520e
chore: sandbox html
adamdehaven Sep 28, 2023
d7d8ebc
chore: permissions
adamdehaven Sep 28, 2023
8e3f72e
chore: use router hash mode
adamdehaven Sep 28, 2023
d39d3a4
chore: use built-in sticky comment
adamdehaven Sep 28, 2023
6659821
chore: disable environment since we use new action
adamdehaven Sep 28, 2023
571584f
chore: sandbox text
adamdehaven Sep 28, 2023
cf4a414
chore: use current branch
adamdehaven Sep 28, 2023
5f56642
chore: update branch
adamdehaven Sep 28, 2023
ce7a136
chore: add token
adamdehaven Sep 28, 2023
31f1e4a
chore: use current branch
adamdehaven Sep 28, 2023
8502deb
chore: fix path
adamdehaven Sep 28, 2023
a2d7e44
chore: update
adamdehaven Sep 28, 2023
d786422
chore: upload artifact
adamdehaven Sep 28, 2023
544a630
chore: preview branch
adamdehaven Sep 28, 2023
acf888a
chore: always deploy
adamdehaven Sep 28, 2023
3e94c04
chore: use branch
adamdehaven Sep 28, 2023
43d0ed6
chore: manual deploy
adamdehaven Sep 28, 2023
4e8f78b
chore: fix output
adamdehaven Sep 28, 2023
c514d90
chore: use artifact
adamdehaven Sep 28, 2023
0b0383b
chore: use artifact
adamdehaven Sep 28, 2023
edf4ae2
chore: fix ci
adamdehaven Sep 28, 2023
344f5ed
chore: fix ci
adamdehaven Sep 28, 2023
600602a
chore: fix ci
adamdehaven Sep 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ cli/template
docs/.vitepress/.temp/
docs/.vitepress/.cache/
docs/.vitepress/dist/

# Ignore files in the GitHub Pages deploy previews
pr-preview/
100 changes: 100 additions & 0 deletions .github/workflows/github-pages-pr-preview.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Deploy Sandbox PR Preview to GitHub Pages

on:
pull_request:
types:
- opened
- reopened
- synchronize
# Ensure previews are cleaned up when PR is closed
- closed
# TODO: Update branch name to beta when needed
branches:
- alpha

concurrency:
group: sandbox-pr-preview-${{ github.ref }}
cancel-in-progress: true

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
pull-requests: write

jobs:
deploy-preview:
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Remove sandbox preview comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
delete: true
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build Sandbox
env:
# Tell the script to use the sandbox directory
USE_SANDBOX: true
run: yarn sandbox:build

# - name: Deploy Sandbox PR Preview to GitHub Pages
# id: pr-preview
# uses: rossjrw/pr-preview-action@v1
# env:
# GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}
# with:
# source-dir: ./sandbox/dist
# preview-branch: ${{ github.head_ref || github.ref_name }}
# umbrella-dir: pr-preview
# token: ${{ secrets.KONGPONENTS_BOT_PAT }}

- name: Log dist contents
run:
|
ls -a sandbox/dist

- name: Generate target folder path
id: target-folder
run: |
echo "target-folder=pr-preview/pr-${{ github.event.number }}" >> $GITHUB_OUTPUT

# TODO: Only run when PR is created; create separate step for when PR is closed to remove pr folder
- name: Deploy Sandbox PR Preview to GitHub Pages
id: pr-preview
uses: JamesIves/github-pages-deploy-action@v4
with:
# TODO: Update branch name to beta when needed
branch: ${{ github.head_ref || github.ref_name }}
folder: sandbox/dist # The sandbox dist directory name
target-folder: ${{ steps.target-folder.outputs.target-folder }}
clean-exclude: pr-preview/ # Do not remove other PR preview builds
force: true
token: ${{ secrets.KONGPONENTS_BOT_PAT }}

- name: Provide sandbox preview link
uses: marocchino/sticky-pull-request-comment@v2
with:
header: pr-preview
message: |
## Sandbox Deploy Preview

https://kong.github.io/kongponents/${{ steps.target-folder.outputs.target-folder }}/
GITHUB_TOKEN: ${{ secrets.KONGPONENTS_BOT_PAT }}
29 changes: 20 additions & 9 deletions .github/workflows/github-pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,22 @@ permissions:
# 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'
group: pages-${{ github.ref }}
cancel-in-progress: false

jobs:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
# environment:
# name: github-pages
# url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
timeout-minutes: 10

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Use Node.js
uses: actions/setup-node@v3
Expand All @@ -55,8 +56,18 @@ jobs:
uses: actions/upload-pages-artifact@v2
with:
# Upload sandbox/dist directory
path: './sandbox/dist'
path: ./sandbox/dist

# - name: Deploy to GitHub Pages
# id: deployment
# uses: actions/deploy-pages@v2

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: JamesIves/github-pages-deploy-action@v4
with:
# TODO: Update branch name to beta when needed
branch: alpha
folder: ./sandbox/dist # The folder the action should deploy.
clean-exclude: pr-preview/ # Do not remove other PR preview builds
force: false
token: ${{ secrets.KONGPONENTS_BOT_PAT }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ docs/.vitepress/.temp
docs/.vitepress/.cache
docs/.vitepress/cache
docs/.vitepress/dist

# Ignore files in the GitHub Pages deploy previews
pr-preview/
12 changes: 8 additions & 4 deletions sandbox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
<html lang="en">

<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Kongponents Sandbox</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="robots" content="noindex nofollow" />
<link rel="icon" href="/favicon.ico">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono&display=swap"
rel="stylesheet">
<title>Kongponents Sandbox</title>
<style>
html,
body {
Expand Down
4 changes: 2 additions & 2 deletions sandbox/pages/HomePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
>
<h2>Welcome to the Sandbox!</h2>
<p>
The sandbox mode in Kongponents provides developers with a controlled environment to test and ensure that no styles from the docs app leak through into the component library. This feature guarantees that the components look and function as intended, without any external interference.
This sandbox (currently pointed to the <code>alpha</code> branch) provides users with a controlled environment to test and interact with components. This feature helps to guarantee that the components look and behave as intended, without external interference.
</p>
<p>
By using the sandbox mode, you can have confidence that components maintain their visual consistency, regardless of the context in which they are used.
By using the sandbox, you can verify that components maintain their visual consistency, regardless of the host app in which they are used.
</p>
</div>
<router-view />
Expand Down
4 changes: 2 additions & 2 deletions sandbox/router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createRouter, createWebHistory } from 'vue-router'
import { createRouter, createWebHashHistory } from 'vue-router'

export default createRouter({
history: createWebHistory('/kongponents'),
history: createWebHashHistory(),
routes: [
{
path: '/',
Expand Down