Skip to content

Commit b8b943b

Browse files
[migrate] upgrade to Vercel CLI 50.x & Open-Source-Bazaar/feishu-action@v3 in GitHub action
1 parent 6c220df commit b8b943b

File tree

1 file changed

+54
-36
lines changed

1 file changed

+54
-36
lines changed

.github/workflows/main.yml

Lines changed: 54 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,53 +10,71 @@ jobs:
1010
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
1111
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
1212
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
1315
steps:
1416
- uses: actions/checkout@v6
1517
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
18+
19+
- uses: actions/setup-node@v6
20+
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
1621
with:
17-
submodules: recursive
18-
lfs: true
19-
- run: git submodule update --remote
22+
node-version: 24
2023

2124
- name: Deploy to Vercel
2225
id: vercel-deployment
23-
uses: amondnet/vercel-action@v25
2426
if: ${{ env.VERCEL_TOKEN && env.VERCEL_ORG_ID && env.VERCEL_PROJECT_ID }}
25-
with:
26-
vercel-token: ${{ secrets.VERCEL_TOKEN }}
27-
github-token: ${{ secrets.GITHUB_TOKEN }}
28-
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
29-
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
30-
working-directory: ./
31-
vercel-args: ${{ github.ref == 'refs/heads/main' && '--prod' || '' }}
27+
shell: bash
28+
run: |
29+
set -euo pipefail
30+
31+
npm install vercel -g
32+
33+
if [[ "$GITHUB_REF" == 'refs/heads/main' ]]; then
34+
DeployOutput=$(vercel -t "$VERCEL_TOKEN" --prod)
35+
else
36+
DeployOutput=$(vercel -t "$VERCEL_TOKEN")
37+
fi
38+
echo "$DeployOutput"
39+
40+
ParsedURL=$(echo "$DeployOutput" | grep -Eo 'https://[^[:space:]]*\.vercel\.app' | tail -n 1)
41+
42+
if [[ -z "$ParsedURL" ]]; then
43+
echo "Failed to parse Vercel URL from deploy output"
44+
exit 1
45+
fi
46+
vercel inspect "$ParsedURL" -t "$VERCEL_TOKEN" -F json > vercel-inspect.json
47+
48+
InspectURL=$(jq -r '.url // empty' vercel-inspect.json)
49+
50+
if [[ -z "$InspectURL" ]]; then
51+
echo "Failed to parse inspect url from vercel-inspect.json"
52+
exit 1
53+
fi
54+
if [[ "$InspectURL" != http* ]]; then
55+
InspectURL="https://$InspectURL"
56+
fi
57+
echo "preview-url=$InspectURL" >> "$GITHUB_OUTPUT"
3258
3359
- name: Lark notification
3460
uses: Open-Source-Bazaar/feishu-action@v3
3561
with:
3662
url: ${{ secrets.LARK_CHATBOT_HOOK_URL }}
37-
msg_type: post
63+
msg_type: interactive
3864
content: |
39-
post:
40-
zh_cn:
41-
title: Vercel 预览环境
42-
content:
43-
- - tag: text
44-
text: Git 仓库:
45-
- tag: a
46-
text: ${{ github.server_url }}/${{ github.repository }}
47-
href: ${{ github.server_url }}/${{ github.repository }}
48-
- - tag: text
49-
text: 代码分支:
50-
- tag: a
51-
text: ${{ github.ref }}
52-
href: ${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}
53-
- - tag: text
54-
text: 提交作者:
55-
- tag: a
56-
text: ${{ github.actor }}
57-
href: ${{ github.server_url }}/${{ github.actor }}
58-
- - tag: text
59-
text: 预览链接:
60-
- tag: a
61-
text: ${{ steps.vercel-deployment.outputs.preview-url }}
62-
href: ${{ steps.vercel-deployment.outputs.preview-url }}
65+
schema: "2.0"
66+
config:
67+
wide_screen_mode: true
68+
header:
69+
title:
70+
tag: plain_text
71+
content: Vercel 部署通知
72+
template: blue
73+
body:
74+
elements:
75+
- tag: markdown
76+
content: |
77+
**Git 仓库:** [${{ github.server_url }}/${{ github.repository }}](${{ github.server_url }}/${{ github.repository }})
78+
**代码分支:** [${{ github.ref }}](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }})
79+
**提交作者:** [${{ github.actor }}](${{ github.server_url }}/${{ github.actor }})
80+
**预览链接:** [${{ steps.vercel-deployment.outputs.preview-url }}](${{ steps.vercel-deployment.outputs.preview-url }})

0 commit comments

Comments
 (0)