| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- # 当分支 main 有 push 事件,并且此次 push 包含了 demo 目录下的文件时触发,使用 GitHub Actions。
- name: Auto sync 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 git@github.com:dufu1991/stdf.git
- # 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
|