Procházet zdrojové kódy

Add auto sync demo workflow

杜府 před 3 roky
rodič
revize
adc52a6264
3 změnil soubory, kde provedl 51 přidání a 8 odebrání
  1. 47 0
      .github/workflows/auto-sync-demo.yml
  2. 2 4
      README.md
  3. 2 4
      README_en.md

+ 47 - 0
.github/workflows/auto-sync-demo.yml

@@ -0,0 +1,47 @@
+# 当分支 main 有 push 事件,并且此次 push 包含了 demo 目录下的文件时触发,使用 GitHub Actions。
+
+name: Auto deploy demo
+
+on:
+    push:
+        branches:
+            - main
+        paths:
+            - 'demo/**'
+
+jobs:
+    build-and-deploy:
+        runs-on: ubuntu-latest
+        steps:
+            - name: Checkout
+              uses: actions/checkout@v2
+
+            # 1. clone 仓库 github.com/dufu1991/stdf
+            - name: Clone stdf
+              run: |
+                  git clone
+
+            # 2. cd 到 stdf 仓库的 demo 文件内,初始化本地仓库
+            #    将 demo/src/App.svelte 文件内的 ../../components 替换为 stdf
+            #    将 demo/src/pages 目录下的所有子孙 .svelte 文件内的 ../../../../components 替换为 stdf
+            #    将 demo 目录下的所有文件提交到本地仓库,提交信息为 Github Actions auto commit: update demo from stdf.
+            - name: Init stdf demo
+              run: |
+                  cd stdf/demo
+                  git init
+                  git config --global user.name 'GitHub Actions'
+                  git config --global user.email 'GitHub Actions'
+                  sed -i 's|../../components|stdf|g' src/App.svelte
+                  sed -i 's|../../../../components|stdf|g' src/pages/**/*.svelte
+                  git add .
+                  git commit -am "Github Actions auto commit: update demo from stdf."
+
+            # 3. 使用 secrets.GITHUB_TOKEN 将修改内容推送到 git@github.com:dufu1991/demo-stdf.git 的 main 分支
+            - name: Push to demo-stdf
+              uses: ad-m/github-push-action@master
+              with:
+                  github_token: ${{ secrets.STDF_GITHUB_TOKEN }}
+                  branch: main
+                  force: true
+                  directory: stdf/demo
+                  repository: dufu1991/demo-stdf

+ 2 - 4
README.md

@@ -67,9 +67,9 @@ import { Button } from 'stdf';
 
 😓 无工程?用 Vite 示例创建工程,参考 [Vite 文档](https://cn.vitejs.dev/guide/#scaffolding-your-first-vite-project)。并配置 Tailwind CSS,参考 [Tailwind CSS 文档](https://tailwindcss.com/docs/guides/vite)。
 
-# 手机预览
+# 预览
 
-手机扫描以下二维码访问手机端 Demo:
+扫描二维码访问移动端 Demo:
 
 <picture>
   <source media="(prefers-color-scheme: dark)" srcset="https://stdf.design/assets/qr/demo_zh_dark.png">
@@ -82,8 +82,6 @@ import { Button } from 'stdf';
 
 # 贡献者
 
-感谢所有为 STDF 做过贡献的人!
-
 <a href="https://github.com/dufu1991/stdf/graphs/contributors">
   <img src="https://contrib.rocks/image?repo=dufu1991/stdf" />
 </a>

+ 2 - 4
README_en.md

@@ -65,9 +65,9 @@ import { Button } from 'stdf';
 
 😓 No project? Create a project with Vite and reference the [Vite documentation](https://vitejs.dev/guide/#scaffolding-your-first-vite-project) and the [Tailwind CSS documentation](https://tailwindcss.com/docs/guides/vite) for CSS configuration.
 
-# Mobile Preview
+# Preview
 
-You can scan the QR code below on your mobile phone to access the mobile demo:
+Please scan the QR code to access the mobile demo:
 
 <picture>
   <source media="(prefers-color-scheme: dark)" srcset="https://stdf.design/assets/qr/demo_en_dark.png">
@@ -80,8 +80,6 @@ This project is licensed under the [MIT License](https://github.com/dufu1991/std
 
 # Contributors
 
-Thanks to all the people who contribute to STDF!
-
 <a href="https://github.com/dufu1991/stdf/graphs/contributors">
   <img src="https://contrib.rocks/image?repo=dufu1991/stdf" />
 </a>