mirror of
https://github.com/dream-num/univer.git
synced 2026-10-28 02:56:00 +08:00
243 lines
8.6 KiB
YAML
243 lines
8.6 KiB
YAML
name: 📤 Preview Deploy
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- 🎬 Setup
|
|
types:
|
|
- completed
|
|
|
|
permissions:
|
|
contents: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
setup:
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
id: ${{ steps.pr.outputs.value }}
|
|
ref: ${{ steps.ref.outputs.value }}
|
|
repo: ${{ steps.repo.outputs.value }}
|
|
|
|
steps:
|
|
# Get PR id from artifact
|
|
- name: download pr artifact
|
|
uses: dawidd6/action-download-artifact@v9
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: pr-id
|
|
|
|
- name: get PR id
|
|
id: pr
|
|
run: echo "value=$(<pr-id.txt)" >> $GITHUB_OUTPUT
|
|
|
|
# Get PR ref from artifact
|
|
- name: download pr artifact
|
|
uses: dawidd6/action-download-artifact@v9
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: pr-ref
|
|
|
|
- name: get PR ref
|
|
id: ref
|
|
run: echo "value=$(<pr-ref.txt)" >> $GITHUB_OUTPUT
|
|
|
|
# Get PR repo from artifact
|
|
- name: download pr artifact
|
|
uses: dawidd6/action-download-artifact@v9
|
|
with:
|
|
workflow: ${{ github.event.workflow_run.workflow_id }}
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
name: pr-repo
|
|
|
|
- name: get PR repo
|
|
id: repo
|
|
run: echo "value=$(<pr-repo.txt)" >> $GITHUB_OUTPUT
|
|
|
|
prepare:
|
|
runs-on: ubuntu-latest
|
|
needs: [setup]
|
|
|
|
steps:
|
|
# ================= Create Comment =================
|
|
- name: 🧽 Find And Delete Comment
|
|
uses: peter-evans/find-comment@v2
|
|
if: ${{ needs.setup.outputs.id != '' }}
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ needs.setup.outputs.id }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: View Deployment
|
|
|
|
- name: 📝 Create or update comment
|
|
uses: peter-evans/create-or-update-comment@v3
|
|
if: ${{ needs.setup.outputs.id != '' }}
|
|
with:
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
issue-number: ${{ needs.setup.outputs.id }}
|
|
body: |
|
|
## View Deployment
|
|
|
|
[#${{ github.run_id }}](https://github.com/dream-num/univer/actions/runs/${{ github.run_id }})
|
|
|
|
<p align="center">
|
|
🥐 🍔 🥓 🥗 🥘 🌯 🍚 🍛 🍖 🍭 🍧 🍝 🥪 🥖 🍪 <br />
|
|
Still cooking, please come back later <br />
|
|
🥙 🥮 🥨 🌭 🍦 🍙 🍕 🍰 🍮 🍜 🍡 🍱 🍿 🍕 🥟
|
|
</p>
|
|
edit-mode: replace
|
|
|
|
build-demo:
|
|
runs-on: ubuntu-latest
|
|
needs: [setup]
|
|
|
|
outputs:
|
|
preview-url: ${{ steps.vercel-demo-dev.outputs.preview-url == '' && steps.vercel-demo.outputs.preview-url || steps.vercel-demo-dev.outputs.preview-url }}
|
|
commit-message: ${{ steps.commit-message.outputs.value }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ needs.setup.outputs.repo }}
|
|
ref: ${{ needs.setup.outputs.ref }}
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
run_install: false
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24.3.0
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
- name: Get commit message
|
|
id: commit-message
|
|
run: echo "value=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
|
|
|
|
# ================= Deploy Demo =================
|
|
- name: 📦 Build demo
|
|
run: pnpm build:demo
|
|
|
|
- name: Copy demo to workspace
|
|
run: |
|
|
mkdir .workspace
|
|
cp -r ./examples/local/* .workspace
|
|
|
|
- name: 📦 Build react16 demo
|
|
run: |
|
|
pnpm use:react16
|
|
pnpm build:demo
|
|
|
|
- name: Copy demo to workspace
|
|
run: |
|
|
mkdir .workspace/react16
|
|
cp -r ./examples/local/* .workspace/react16
|
|
|
|
- name: 🚀 Deploy to Vercel (demo)
|
|
uses: amondnet/vercel-action@v25
|
|
if: ${{ needs.setup.outputs.ref == '' }}
|
|
id: vercel-demo
|
|
with:
|
|
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
vercel-org-id: ${{ secrets.ORG_ID }}
|
|
vercel-project-id: ${{ secrets.PROJECT_ID}}
|
|
vercel-args: --prod
|
|
|
|
- name: 🚀 Deploy to Vercel (demo)
|
|
uses: amondnet/vercel-action@v25
|
|
if: ${{ needs.setup.outputs.ref != '' }}
|
|
id: vercel-demo-dev
|
|
with:
|
|
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
vercel-org-id: ${{ secrets.ORG_ID }}
|
|
vercel-project-id: ${{ secrets.PROJECT_ID}}
|
|
|
|
build-storybook:
|
|
runs-on: ubuntu-latest
|
|
needs: [setup]
|
|
|
|
outputs:
|
|
preview-url: ${{ steps.vercel-storybook-dev.outputs.preview-url == '' && steps.vercel-storybook.outputs.preview-url || steps.vercel-storybook-dev.outputs.preview-url }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: ${{ needs.setup.outputs.repo }}
|
|
ref: ${{ needs.setup.outputs.ref }}
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v4
|
|
with:
|
|
run_install: false
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 24.3.0
|
|
cache: pnpm
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install
|
|
|
|
# ================= Deploy Storybook =================
|
|
- name: 📦 Build storybook
|
|
run: pnpm storybook:build
|
|
|
|
- name: 🚀 Deploy to Vercel (demo)
|
|
uses: amondnet/vercel-action@v25
|
|
if: ${{ needs.setup.outputs.ref == '' }}
|
|
id: vercel-storybook
|
|
with:
|
|
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
vercel-org-id: ${{ secrets.ORG_ID }}
|
|
vercel-project-id: ${{ secrets.PROJECT_ID_STORYBOOK}}
|
|
vercel-args: --prod
|
|
|
|
- name: 🚀 Deploy to Vercel (storybook)
|
|
uses: amondnet/vercel-action@v25
|
|
if: ${{ needs.setup.outputs.ref != '' }}
|
|
id: vercel-storybook-dev
|
|
with:
|
|
vercel-token: ${{ secrets.VERCEL_TOKEN }}
|
|
vercel-org-id: ${{ secrets.ORG_ID }}
|
|
vercel-project-id: ${{ secrets.PROJECT_ID_STORYBOOK}}
|
|
|
|
notify:
|
|
runs-on: ubuntu-latest
|
|
needs: [setup, build-demo, build-storybook]
|
|
|
|
steps:
|
|
# ================= Create Comment =================
|
|
- name: 🧽 Find And Delete Comment
|
|
uses: peter-evans/find-comment@v2
|
|
if: ${{ needs.setup.outputs.id != '' }}
|
|
id: fc
|
|
with:
|
|
issue-number: ${{ needs.setup.outputs.id }}
|
|
comment-author: 'github-actions[bot]'
|
|
body-includes: View Deployment
|
|
|
|
- name: 📝 Create or update comment
|
|
uses: peter-evans/create-or-update-comment@v3
|
|
if: ${{ needs.setup.outputs.id != '' }}
|
|
with:
|
|
comment-id: ${{ steps.fc.outputs.comment-id }}
|
|
issue-number: ${{ needs.setup.outputs.id }}
|
|
body: |
|
|
## View Deployment
|
|
| 📑 Demo (React@19) | Demo (React@16) | 📚 Storybook |
|
|
| --- | --- | --- |
|
|
| [🔗 Preview link](${{ needs.build-demo.outputs.preview-url }}/) | [🔗 Preview link](${{ needs.build-demo.outputs.preview-url }}/react16/) | [🔗 Preview link](${{ needs.build-storybook.outputs.preview-url }}/) |
|
|
edit-mode: replace
|