-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (81 loc) · 3.34 KB
/
Copy pathdeploy.yml
File metadata and controls
94 lines (81 loc) · 3.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Build & Deploy Astro to COS
on:
push:
branches:
- master
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true
jobs:
build-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Build Astro site
run: npm run build
- name: Upload to COS (Tencent Cloud)
uses: Robert-Stackflow/upload-s3-action@master
with:
endpoint: ${{ secrets.AWS_ENDPOINT }}
aws_key_id: ${{ secrets.AWS_SECRET_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws_bucket: ${{ secrets.AWS_BUCKET }}
source_dir: dist
destination_dir: /
- name: Send PushPlus Notification
if: always()
run: |
# 拼接当前 workflow 日志地址
LOG_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
# 获取当前时间
BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S')
# CI 信息
WORKFLOW_NAME="${{ github.workflow }}"
JOB_NAME="${{ github.job }}"
if [ "${{ job.status }}" = "success" ]; then
STATUS_MSG="<h3 style='color:green;'>Homepage 网站部署成功</h3>
<table border='1' cellpadding='6' cellspacing='0'>
<tr><th colspan='2'>CI 信息</th></tr>
<tr><td>Workflow</td><td>${WORKFLOW_NAME}</td></tr>
<tr><td>Job</td><td>${JOB_NAME}</td></tr>
<tr><td>构建时间</td><td>${BUILD_TIME}</td></tr>
</table>
<br>
<table border='1' cellpadding='6' cellspacing='0'>
<tr><th colspan='2'>部署信息</th></tr>
<tr><td>状态</td><td>已构建并上传至 COS</td></tr>
<tr><td>分支</td><td>${{ github.ref_name }}</td></tr>
<tr><td>日志</td><td><a href='${LOG_URL}'>查看日志</a></td></tr>
</table>"
else
STATUS_MSG="<h3 style='color:red;'>Homepage 网站部署失败</h3>
<table border='1' cellpadding='6' cellspacing='0'>
<tr><th colspan='2'>CI 信息</th></tr>
<tr><td>Workflow</td><td>${WORKFLOW_NAME}</td></tr>
<tr><td>Job</td><td>${JOB_NAME}</td></tr>
<tr><td>构建时间</td><td>${BUILD_TIME}</td></tr>
</table>
<br>
<table border='1' cellpadding='6' cellspacing='0'>
<tr><th colspan='2'>部署信息</th></tr>
<tr><td>状态</td><td>部署出错,请检查 GitHub Actions 日志</td></tr>
<tr><td>分支</td><td>${{ github.ref_name }}</td></tr>
<tr><td>日志</td><td><a href='${LOG_URL}'>查看日志</a></td></tr>
</table>"
fi
curl -X POST \
-H "Content-Type: application/json" \
-d "{
\"token\": \"${{ secrets.PUSHPLUS_TOKEN }}\",
\"title\": \"Homepage 网站部署结果通知\",
\"content\": \"${STATUS_MSG}\",
\"template\": \"html\"
}" \
https://www.pushplus.plus/send