|
| 1 | +name: Sync Main to Examples |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - "config/source/skills/**" |
| 9 | + - "config/source/guideline/**" |
| 10 | + - "config/source/editor-config/**" |
| 11 | + - "scripts/build-compat-config.mjs" |
| 12 | + - "scripts/diff-compat-config.mjs" |
| 13 | + - "scripts/update-compat-baseline.mjs" |
| 14 | + - "scripts/sync-config.mjs" |
| 15 | + - "scripts/template-config.json" |
| 16 | + - ".github/workflows/sync-main-to-examples.yml" |
| 17 | + |
| 18 | +concurrency: |
| 19 | + group: sync-main-to-examples |
| 20 | + cancel-in-progress: false |
| 21 | + |
| 22 | +jobs: |
| 23 | + sync: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + steps: |
| 28 | + - name: Checkout current repo |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Checkout cloudbase-examples |
| 32 | + uses: actions/checkout@v4 |
| 33 | + with: |
| 34 | + repository: TencentCloudBase/awsome-cloudbase-examples |
| 35 | + ref: master |
| 36 | + path: cloudbase-examples |
| 37 | + token: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }} |
| 38 | + |
| 39 | + - name: Setup Node.js |
| 40 | + uses: actions/setup-node@v4 |
| 41 | + with: |
| 42 | + node-version: '22' |
| 43 | + |
| 44 | + - name: Validate compatibility surface |
| 45 | + run: node scripts/diff-compat-config.mjs |
| 46 | + |
| 47 | + - name: Check git status before sync |
| 48 | + working-directory: cloudbase-examples |
| 49 | + run: | |
| 50 | + echo "=== Git status before sync ===" |
| 51 | + git status --short || true |
| 52 | +
|
| 53 | + - name: Sync config to examples |
| 54 | + run: node scripts/sync-config.mjs --skip-git |
| 55 | + env: |
| 56 | + CLOUDBASE_EXAMPLES_PATH: cloudbase-examples |
| 57 | + |
| 58 | + - name: Check git status after sync |
| 59 | + working-directory: cloudbase-examples |
| 60 | + run: | |
| 61 | + echo "=== Git status after sync ===" |
| 62 | + git status --short |
| 63 | + echo "=== Files changed ===" |
| 64 | + git diff --name-only || echo "No changes detected" |
| 65 | + echo "=== Staged files ===" |
| 66 | + git diff --staged --name-only || echo "No staged files" |
| 67 | +
|
| 68 | + - name: Commit and push changes |
| 69 | + working-directory: cloudbase-examples |
| 70 | + env: |
| 71 | + PAT_TOKEN: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }} |
| 72 | + run: | |
| 73 | + git config user.name "github-actions[bot]" |
| 74 | + git config user.email "github-actions[bot]@users.noreply.github.com" |
| 75 | + git add . |
| 76 | + if git diff --staged --quiet; then |
| 77 | + echo "No changes to commit, skipping commit and push" |
| 78 | + else |
| 79 | + git commit -m "chore: sync config from main" |
| 80 | + git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/TencentCloudBase/awsome-cloudbase-examples.git |
| 81 | + git push origin master |
| 82 | + fi |
0 commit comments