-
Notifications
You must be signed in to change notification settings - Fork 126
99 lines (89 loc) · 3.21 KB
/
build-zips.yml
File metadata and controls
99 lines (89 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Build Example Zips
on:
workflow_dispatch:
inputs:
source_branch:
description: 'Source branch (this repo)'
required: false
default: 'main'
target_branch:
description: 'Target branch (cloudbase-examples)'
required: false
default: 'master'
build_zips:
description: 'Build zip files'
type: boolean
default: true
commit_changes:
description: 'Commit changes to cloudbase-examples'
type: boolean
default: false
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- name: Checkout current repo
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.source_branch || 'main' }}
- name: Checkout cloudbase-examples
uses: actions/checkout@v4
with:
repository: TencentCloudBase/awsome-cloudbase-examples
ref: ${{ github.event.inputs.target_branch || 'master' }}
path: cloudbase-examples
token: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
- name: Check git status before sync
working-directory: cloudbase-examples
run: |
echo "=== Git status before sync ==="
git status --short || true
- name: Sync config to examples
run: node scripts/sync-config.mjs --skip-git
env:
CLOUDBASE_EXAMPLES_PATH: cloudbase-examples
- name: Check git status after sync
working-directory: cloudbase-examples
run: |
echo "=== Git status after sync ==="
git status --short
echo "=== Files changed ==="
git diff --name-only || echo "No changes detected"
echo "=== Staged files ==="
git diff --staged --name-only || echo "No staged files"
- name: Build zips
if: github.event.inputs.build_zips == 'true'
working-directory: cloudbase-examples
run: |
rm -rf dist
node scripts/build-zips.js
- name: Upload artifact
if: github.event.inputs.build_zips == 'true'
uses: actions/upload-artifact@v4
with:
name: cloudbase-examples-zips
path: cloudbase-examples/dist
retention-days: 30
- name: Commit and push changes
if: github.event.inputs.commit_changes == 'true'
working-directory: cloudbase-examples
env:
PAT_TOKEN: ${{ secrets.CLOUDBASE_EXAMPLES_TOKEN }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
if git diff --staged --quiet; then
echo "No changes to commit, skipping commit and push"
else
git commit -m "chore: sync config from ${{ github.event.inputs.source_branch || 'main' }}"
git remote set-url origin https://x-access-token:${PAT_TOKEN}@github.com/TencentCloudBase/awsome-cloudbase-examples.git
git push origin ${{ github.event.inputs.target_branch || 'master' }}
fi