๐ค Preview Deploy #57
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ๐ค Preview Deploy | |
on: | |
workflow_run: | |
workflows: | |
- ๐ฆ Build | |
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@v2 | |
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@v2 | |
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@v2 | |
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-icons/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.outputs.preview-url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ needs.setup.outputs.repo }} | |
ref: ${{ needs.setup.outputs.ref }} | |
- name: Setup Node.js | |
uses: ./.github/actions/setup-node | |
- name: ๐ฆ Build @univerjs/icons | |
run: pnpm generate && pnpm build | |
# ================= Deploy Demo ================= | |
- name: ๐ฆ Build site | |
run: pnpm run build:site | |
- name: Copy demo to workspace | |
run: | | |
mkdir .workspace | |
cp -r ./doc/build/* .workspace | |
- 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.VERCEL_ORG_ID }} | |
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} | |
notify: | |
runs-on: ubuntu-latest | |
needs: [setup, build-demo] | |
steps: | |
- name: Invoke deployment hook | |
uses: distributhor/workflow-webhook@v3 | |
with: | |
webhook_url: ${{ secrets.WEBHOOK_URL }} | |
data: > | |
{ | |
"type": "build", | |
"workflow": { | |
"id": "${{ github.run_id }}" | |
}, | |
"commit": { | |
"ref": "${{ needs.setup.outputs.ref }}", | |
"message": "${{ github.event.workflow_run.head_commit.message }}", | |
"id": "${{ github.event.workflow_run.head_commit.id }}", | |
"author": "${{ github.event.workflow_run.head_commit.author.name }}" | |
}, | |
"preview": { | |
"๐ Preview": "${{ needs.build-demo.outputs.preview-url }}/" | |
} | |
} | |
# ================= 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 | |
| ๐ Preview | | |
| --- | | |
| [๐ Preview link](${{ needs.build-demo.outputs.preview-url }}/) | | |
edit-mode: replace |