This is an automated email from the ASF dual-hosted git repository.

liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 07ae5854 infra: add auto sync GHA (#549)
07ae5854 is described below

commit 07ae58544a66b73870e8648bfeb1a2afe85717eb
Author: shown <[email protected]>
AuthorDate: Tue Sep 30 09:31:49 2025 +0800

    infra: add auto sync GHA (#549)
    
    Signed-off-by: yuluo-yx <[email protected]>
---
 .github/workflows/sync-to-main.yml | 101 +++++++++++++++++++++++++++++++++++++
 1 file changed, 101 insertions(+)

diff --git a/.github/workflows/sync-to-main.yml 
b/.github/workflows/sync-to-main.yml
new file mode 100644
index 00000000..ee535608
--- /dev/null
+++ b/.github/workflows/sync-to-main.yml
@@ -0,0 +1,101 @@
+name: Sync Dashboard Build to Main Repository
+
+on:
+  push:
+    branches:
+      - master
+  workflow_dispatch: 
+
+jobs:
+  sync:
+    runs-on: ubuntu-latest
+    if: github.repository == 'apache/shenyu-dashboard'
+    
+    steps:
+      - name: Checkout dashboard repository
+        uses: actions/checkout@v4
+        with:
+          fetch-depth: 0
+          
+      - name: Setup Node.js
+        uses: actions/setup-node@v4
+        with:
+          node-version: '16'
+          cache: 'npm'
+          
+      - name: Install dependencies
+        run: npm ci
+        
+      - name: Build project
+        run: npm run build
+        
+      - name: Checkout main repository
+        uses: actions/checkout@v4
+        with:
+          repository: apache/shenyu
+          token: ${{ secrets.GH_PAT }}
+          path: shenyu-main
+          fetch-depth: 0
+          
+      - name: Check for changes and sync
+        run: |
+          mkdir -p shenyu-main/shenyu-admin/src/main/resources/static
+          
+          # check different.
+          if ! diff -r dist/ 
shenyu-main/shenyu-admin/src/main/resources/static/ > /dev/null 2>&1; then
+            echo "Changes detected, syncing files..."
+            
+            # check change,start sync code
+            rm -rf shenyu-main/shenyu-admin/src/main/resources/static/*
+            cp -r dist/* shenyu-main/shenyu-admin/src/main/resources/static/
+            
+            # create pull request git config
+            cd shenyu-main
+            git config --local user.email "[email protected]"
+            git config --local user.name "GitHub Action"
+            
+            # create new branch to sync code
+            BRANCH_NAME="sync-dashboard-$(date +%Y%m%d-%H%M%S)"
+            git checkout -b "$BRANCH_NAME"
+            
+            # commit changes
+            git add shenyu-admin/src/main/resources/static/
+            git commit -m "admin(dashboard): sync dashboard build from 
apache/shenyu-dashboard@${{ github.sha }}
+            
+            Auto-sync dashboard build artifacts from shenyu-dashboard 
repository.
+            
+            Source commit: ${{ github.sha }}
+            Workflow run: ${{ github.server_url }}/${{ github.repository 
}}/actions/runs/${{ github.run_id }}"
+            
+            # push
+            git push origin "$BRANCH_NAME"
+            
+            # create pull request
+            gh pr create \
+              --title "chore: sync dashboard build artifacts" \
+              --body "Auto-sync dashboard build artifacts from 
apache/shenyu-dashboard.
+
+            **Source Details:**
+            - Repository: apache/shenyu-dashboard  
+            - Commit: ${{ github.sha }}
+            - Workflow: ${{ github.server_url }}/${{ github.repository 
}}/actions/runs/${{ github.run_id }}
+            
+            This PR contains the latest build artifacts from the dashboard 
repository." \
+              --head "$BRANCH_NAME" \
+              --base master
+              
+            echo "✅ Pull request created successfully"
+          else
+            echo "No changes detected, skipping sync"
+          fi
+        env:
+          GH_TOKEN: ${{ secrets.GH_PAT }}
+          
+      - name: Result Output
+        run: |
+          echo "## Sync Summary" >> $GITHUB_STEP_SUMMARY
+          echo "- **Source Repository**: apache/shenyu-dashboard" >> 
$GITHUB_STEP_SUMMARY  
+          echo "- **Source Commit**: ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
+          echo "- **Target Repository**: apache/shenyu" >> $GITHUB_STEP_SUMMARY
+          echo "- **Target Path**: shenyu-admin/src/main/resources/static" >> 
$GITHUB_STEP_SUMMARY
+          echo "- **Build Status**: ✅ Completed" >> $GITHUB_STEP_SUMMARY

Reply via email to