Last active
December 18, 2025 08:46
-
-
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 Dev" | |
| run-name: "Deploy Dev" | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| - "main" | |
| env: | |
| NOTIFY_URL: https://open.feishu.cn/open-apis/bot/v2/hook/0e8122b9-e5cf-43e5-ab57-da4fc84d5e14 | |
| PUBLIC_URL: https://${{ github.event.repository.name }}.d.outbox.website/ | |
| WORKSPACE_DIR: /outbox-website-workspace/${{ github.repository }} | |
| WEBSITE_OUTPUT_DIR: /outbox-website-output/${{ github.event.repository.name }} | |
| jobs: | |
| pull-code: | |
| runs-on: | |
| group: outbox-dev | |
| labels: [ 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 ${{ env.WORKSPACE_DIR }} | |
| if [ $? -eq 0 ]; then | |
| echo "✅ 克隆成功" | |
| ls -la ${{ env.WORKSPACE_DIR }} | |
| else | |
| echo "❌ 克隆失败" | |
| exit 1 | |
| fi | |
| deploy-frontend: | |
| runs-on: | |
| group: outbox-dev | |
| labels: [ 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 }}" | |
| chmod 777 ${{ env.WEBSITE_OUTPUT_DIR }} | |
| echo "✅ 更新目录权限" | |
| fi | |
| sudo cp -r ${{ env.WORKSPACE_DIR }}/www/* ${{ env.WEBSITE_OUTPUT_DIR }} | |
| if [ $? -eq 0 ]; then | |
| echo "frontend_status=success" >> $GITHUB_OUTPUT | |
| echo "✅ 复制完成" | |
| sudo chown -R www-data:www-data ${{ env.WEBSITE_OUTPUT_DIR }} | |
| echo "✅ 更新目录所有权" | |
| else | |
| echo "frontend_status=failed" >> $GITHUB_OUTPUT | |
| echo "❌ 复制失败" | |
| fi | |
| notify: | |
| runs-on: | |
| group: outbox-dev | |
| labels: [ 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="[Dev] ${{ 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\"}}" | |
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 Release" | |
| run-name: "Deploy Release" | |
| on: | |
| push: | |
| branches: | |
| - "master" | |
| - "main" | |
| env: | |
| NOTIFY_URL: https://open.feishu.cn/open-apis/bot/v2/hook/0e8122b9-e5cf-43e5-ab57-da4fc84d5e14 | |
| 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: | |
| group: outbox-release | |
| labels: [ 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 ${{ env.WORKSPACE_DIR }} | |
| if [ $? -eq 0 ]; then | |
| echo "✅ 克隆成功" | |
| ls -la ${{ env.WORKSPACE_DIR }} | |
| else | |
| echo "❌ 克隆失败" | |
| exit 1 | |
| fi | |
| deploy-frontend: | |
| runs-on: | |
| group: outbox-release | |
| labels: [ 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 }}" | |
| chmod 777 ${{ env.WEBSITE_OUTPUT_DIR }} | |
| echo "✅ 更新目录权限" | |
| fi | |
| sudo cp -r ${{ env.WORKSPACE_DIR }}/www/* ${{ env.WEBSITE_OUTPUT_DIR }} | |
| if [ $? -eq 0 ]; then | |
| echo "frontend_status=success" >> $GITHUB_OUTPUT | |
| echo "✅ 复制完成" | |
| sudo chown -R www-data:www-data ${{ env.WEBSITE_OUTPUT_DIR }} | |
| echo "✅ 更新目录所有权" | |
| else | |
| echo "frontend_status=failed" >> $GITHUB_OUTPUT | |
| echo "❌ 复制失败" | |
| fi | |
| notify: | |
| runs-on: | |
| group: outbox-release | |
| labels: [ 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="[Release] ${{ 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