Last active
December 2, 2025 13:12
-
-
Save flxxyz/622f1af237e67754f0b88ac812c68148 to your computer and use it in GitHub Desktop.
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: "Deploy" | |
| run-name: "Deploy" | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| - "main" | |
| env: | |
| NOTIFY_URL: https://open.feishu.cn/open-apis/bot/v2/hook/c56803c6-3b3f-48a1-b851-9e57d4626645 | |
| PUBLIC_URL: https://${{ github.event.repository.name }}.outbox.website/ | |
| WORKSPACE_DIR: /outbox-website-workspace/${{ github.repository }} | |
| WEBSITE_OUTPUT_DIR: /outbox-website-output/${{ github.event.repository.name }} | |
| jobs: | |
| pull-code: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Check out the repo | |
| env: | |
| TOKEN: ${{ secrets.PAT_TOKEN }} | |
| run: | | |
| rm -rf ${{ env.WORKSPACE_DIR }} | |
| git clone https://${TOKEN}@github.com/${{ github.repository }}.git $WORKSPACE_DIR | |
| if [ $? -eq 0 ]; then | |
| echo "✅ 克隆成功" | |
| ls -la | |
| else | |
| echo "❌ 克隆失败" | |
| exit 1 | |
| fi | |
| deploy-frontend: | |
| runs-on: self-hosted | |
| needs: pull-code | |
| outputs: | |
| frontend_status: ${{ steps.deploy-frontend.outputs.frontend_status }} | |
| steps: | |
| - name: Deploy Frontend | |
| id: deploy-frontend | |
| run: | | |
| if [ ! -d "${{ env.WEBSITE_OUTPUT_DIR }}" ]; then | |
| mkdir -p ${{ env.WEBSITE_OUTPUT_DIR }} | |
| echo "输出目录不存在,创建 ${{ env.WEBSITE_OUTPUT_DIR }}" | |
| fi | |
| cp -r ${{ env.WORKSPACE_DIR }}/www/* ${{ env.WEBSITE_OUTPUT_DIR }} | |
| if [ $? -eq 0 ]; then | |
| echo "frontend_status=success" >> $GITHUB_OUTPUT | |
| echo "复制完成" | |
| else | |
| echo "frontend_status=failed" >> $GITHUB_OUTPUT | |
| fi | |
| notify: | |
| runs-on: self-hosted | |
| if: always() | |
| needs: [deploy-frontend] | |
| steps: | |
| - name: Notify group members | |
| env: | |
| ACTOR: ${{ github.actor }} | |
| BRANCH: ${{ github.ref_name }} | |
| SHA: ${{ github.sha }} | |
| FRONTEND_STATUS: ${{ needs.deploy-frontend.outputs.frontend_status }} | |
| run: | | |
| NOTIFY_MESSAGE="${{ github.event.repository.name }}触发部署\n\n$PUBLIC_URL\n前端状态: $FRONTEND_STATUS\n提交人: $ACTOR\n提交分支: $BRANCH\n提交时SHA: $SHA\n" | |
| curl -v $NOTIFY_URL \ | |
| -H "content-type: application/json" \ | |
| -d "{\"msg_type\":\"text\",\"content\":{\"text\":\"$NOTIFY_MESSAGE\"}}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment