From 468e87a3f6e1682a3e260028ca952fc9a21002b3 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Tue, 10 Sep 2024 19:01:58 -0300 Subject: [PATCH] chore: publish preview github pages --- .github/workflows/ci-preview.yml | 37 +++++++++++++++++++++++ .gitignore | 2 ++ _templates/package/new/package.json.ejs.t | 1 + apps/uikit-playground/package.json | 4 ++- turbo.json | 4 +++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/ci-preview.yml diff --git a/.github/workflows/ci-preview.yml b/.github/workflows/ci-preview.yml new file mode 100644 index 0000000000000..c315a10bcb59c --- /dev/null +++ b/.github/workflows/ci-preview.yml @@ -0,0 +1,37 @@ +# .github/workflows/ci-preview.yml +name: Deploy PR previews +concurrency: preview-${{ github.ref }} +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed +jobs: + deploy-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: rharkor/caching-for-turbo@v1.5 + if: github.event.action != 'closed' + + - name: Setup NodeJS + uses: ./.github/actions/setup-node + if: github.event.action != 'closed' + with: + node-version: 14.21.3 + cache-modules: true + install: true + + - name: Build + if: github.event.action != 'closed' + run: yarn turbo run build-preview + + - uses: rossjrw/pr-preview-action@v1 + with: + source-dir: .preview + preview-branch: gh-pages + umbrella-dir: pr-preview + action: auto diff --git a/.gitignore b/.gitignore index 4e6e4bb29da9f..dbad2c29a22c9 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,8 @@ yarn-error.log* .history .envrc +.preview + *.sublime-workspace **/.vim/ diff --git a/_templates/package/new/package.json.ejs.t b/_templates/package/new/package.json.ejs.t index 6bee52f55927a..b2827ee3fb89b 100644 --- a/_templates/package/new/package.json.ejs.t +++ b/_templates/package/new/package.json.ejs.t @@ -19,6 +19,7 @@ to: packages/<%= name %>/package.json "test": "jest", "build": "rm -rf dist && tsc -p tsconfig.json", "dev": "tsc -p tsconfig.json --watch --preserveWatchOutput" + "build-preview": "mkdir -p ../../.preview && cp -r ./dist ../../.preview/<%= name.toLowerCase() %>" }, "main": "./dist/index.js", "typings": "./dist/index.d.ts", diff --git a/apps/uikit-playground/package.json b/apps/uikit-playground/package.json index d309c2d545994..634e7ef7074f4 100644 --- a/apps/uikit-playground/package.json +++ b/apps/uikit-playground/package.json @@ -5,7 +5,9 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build-preview": "yarn .:build-preview && yarn .:build-preview-move", + ".:build-preview": "tsc && vite build", + ".:build-preview-move": "mkdir -p ../../.preview/ && mv ./dist ../../.preview/uikit-playground", "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "preview": "vite preview" }, diff --git a/turbo.json b/turbo.json index 7ce868eb37070..90ff967485edf 100644 --- a/turbo.json +++ b/turbo.json @@ -2,6 +2,10 @@ "$schema": "https://turborepo.org/schema.json", "globalDependencies": ["tsconfig.base.json", "tsconfig.base.server.json", "tsconfig.base.client.json"], "tasks": { + "build-preview": { + "dependsOn": ["^build"], + "outputs": ["storybook-static/**", ".storybook/**", "dist/**"] + }, "build": { "dependsOn": ["^build"], "outputs": ["dist/**"]