feat: 更新部署通知格式,增加分支和日志链接信息 #10
This file contains hidden or 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: 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 |