|
1 | | -name: Sync Markdown to Site Branch |
| 1 | +name: Trigger Deploy on Master Push |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
|
7 | 7 | workflow_dispatch: |
8 | 8 |
|
9 | 9 | permissions: |
10 | | - contents: write |
11 | 10 | actions: write |
12 | 11 |
|
13 | 12 | jobs: |
14 | | - sync: |
| 13 | + trigger-deploy: |
15 | 14 | runs-on: ubuntu-latest |
16 | 15 | steps: |
17 | | - - name: Checkout master branch |
18 | | - uses: actions/checkout@v4 |
19 | | - with: |
20 | | - ref: master |
21 | | - fetch-depth: 0 |
22 | | - |
23 | | - - name: Set up Python |
24 | | - uses: actions/setup-python@v5 |
25 | | - with: |
26 | | - python-version: '3.x' |
27 | | - |
28 | | - - name: Configure Git |
29 | | - run: | |
30 | | - git config user.name "github-actions[bot]" |
31 | | - git config user.email "github-actions[bot]@users.noreply.github.com" |
32 | | -
|
33 | | - - name: Sync markdown files to site branch |
34 | | - run: | |
35 | | - # Fetch all branches |
36 | | - git fetch origin |
37 | | -
|
38 | | - # Check if site branch exists |
39 | | - if git show-ref --verify --quiet refs/remotes/origin/site; then |
40 | | - git checkout site |
41 | | - git pull origin site |
42 | | - else |
43 | | - echo "Error: site branch does not exist. Please create it first." |
44 | | - exit 1 |
45 | | - fi |
46 | | -
|
47 | | - # Get the conversion script from site branch |
48 | | - CONVERT_SCRIPT="scripts/convert_admonitions.py" |
49 | | -
|
50 | | - # Sync README.md from master root -> docs/index.md |
51 | | - # Convert GitHub markdown to MkDocs format (folder links to .md links) |
52 | | - git show master:README.md | sed \ |
53 | | - -e 's|\](mod-clk/)|](mod-clk/README.md)|g' \ |
54 | | - -e 's|\](mod-comp/)|](mod-comp/README.md)|g' \ |
55 | | - -e 's|\](mod-delay/)|](mod-delay/README.md)|g' \ |
56 | | - -e 's|\](mod-env/)|](mod-env/README.md)|g' \ |
57 | | - -e 's|\](mod-eq/)|](mod-eq/README.md)|g' \ |
58 | | - -e 's|\](mod-in-63/)|](mod-in-63/README.md)|g' \ |
59 | | - -e 's|\](mod-jacket/)|](mod-jacket/README.md)|g' \ |
60 | | - -e 's|\](mod-key/)|](mod-key/README.md)|g' \ |
61 | | - -e 's|\](mod-lpg/)|](mod-lpg/README.md)|g' \ |
62 | | - -e 's|\](mod-midi/)|](mod-midi/README.md)|g' \ |
63 | | - -e 's|\](mod-mix/)|](mod-mix/README.md)|g' \ |
64 | | - -e 's|\](mod-noise/)|](mod-noise/README.md)|g' \ |
65 | | - -e 's|\](mod-out-35/)|](mod-out-35/README.md)|g' \ |
66 | | - -e 's|\](mod-out-63/)|](mod-out-63/README.md)|g' \ |
67 | | - -e 's|\](mod-sat/)|](mod-sat/README.md)|g' \ |
68 | | - -e 's|\](mod-seq/)|](mod-seq/README.md)|g' \ |
69 | | - -e 's|\](mod-vcf/)|](mod-vcf/README.md)|g' \ |
70 | | - -e 's|\](mod-vco/)|](mod-vco/README.md)|g' \ |
71 | | - | python3 "$CONVERT_SCRIPT" > docs/index.md |
72 | | -
|
73 | | - # Sync LICENSE.md from master root -> docs/LICENSE.md |
74 | | - git show master:LICENSE.md > docs/LICENSE.md 2>/dev/null || true |
75 | | -
|
76 | | - # List of module directories |
77 | | - MODULES="mod-clk mod-comp mod-delay mod-env mod-eq mod-in-63 mod-jacket mod-key mod-lpg mod-midi mod-mix mod-noise mod-out-35 mod-out-63 mod-sat mod-seq mod-vcf mod-vco" |
78 | | -
|
79 | | - # Sync each module's README.md and images |
80 | | - for mod in $MODULES; do |
81 | | - mkdir -p "docs/$mod" |
82 | | - |
83 | | - # Sync README.md with admonition conversion |
84 | | - if git show "master:$mod/README.md" > /dev/null 2>&1; then |
85 | | - git show "master:$mod/README.md" | python3 "$CONVERT_SCRIPT" > "docs/$mod/README.md" |
86 | | - fi |
87 | | - |
88 | | - # Sync images |
89 | | - for ext in png jpg jpeg gif svg webp; do |
90 | | - for file in $(git ls-tree --name-only "master:$mod/" 2>/dev/null | grep -E "\.$ext$" || true); do |
91 | | - git show "master:$mod/$file" > "docs/$mod/$file" |
92 | | - done |
93 | | - done |
94 | | - done |
95 | | -
|
96 | | - # Stage all changes |
97 | | - git add -A |
98 | | -
|
99 | | - # Commit and push if there are changes |
100 | | - if git diff --staged --quiet; then |
101 | | - echo "No changes to commit" |
102 | | - echo "CHANGES_MADE=false" >> $GITHUB_ENV |
103 | | - else |
104 | | - git commit -m "Sync markdown files from master" |
105 | | - git push origin site |
106 | | - echo "CHANGES_MADE=true" >> $GITHUB_ENV |
107 | | - fi |
108 | | -
|
109 | 16 | - name: Trigger deploy workflow |
110 | | - if: env.CHANGES_MADE == 'true' |
111 | 17 | run: | |
112 | 18 | gh workflow run deploy.yml --ref site |
113 | 19 | env: |
|
0 commit comments