From fc21216e0ba20fdd0b362b08f2a8a3e748bed07f Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Wed, 11 Sep 2024 10:16:46 -0300 Subject: [PATCH] chore: publish preview github pages --- .github/workflows/ci-preview.yml | 44 +++++++++++++++++++++++ .gitignore | 2 ++ _templates/package/new/package.json.ejs.t | 1 + packages/uikit-playground/package.json | 3 +- turbo.json | 8 +++++ 5 files changed, 57 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..18b4b0bef373a --- /dev/null +++ b/.github/workflows/ci-preview.yml @@ -0,0 +1,44 @@ +# .github/workflows/ci-preview.yml +name: Deploy PR previews +concurrency: preview-${{ github.ref }} +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + push: + branches: + - main + - master + - develop +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 + yarn turbo run .:build-preview-move + + - 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/packages/uikit-playground/package.json b/packages/uikit-playground/package.json index d309c2d545994..233e71b719e5d 100644 --- a/packages/uikit-playground/package.json +++ b/packages/uikit-playground/package.json @@ -5,7 +5,8 @@ "type": "module", "scripts": { "dev": "vite", - "build": "tsc && vite build", + "build-preview": "tsc && vite build", + ".:build-preview-move": "mkdir -p ../../.preview/ && cp -r ./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..0ae903f9250d4 100644 --- a/turbo.json +++ b/turbo.json @@ -2,6 +2,14 @@ "$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-preview-move": { + "dependsOn": ["^build-preview"], + "cache": false + }, "build": { "dependsOn": ["^build"], "outputs": ["dist/**"]