[demo]build for cloudflare #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 当分支 next 分支有 push 事件,并且此次 push 包含了 packages/stdf 目录下的文件时触发,使用 GitHub Actions 执行 | |
name: SYNC NEXT DEMO | |
on: | |
push: | |
branches: | |
- next | |
paths: | |
- 'packages/stdf/**' | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# clone 仓库 github.com/any-tdf/stdf | |
- name: Clone stdf | |
uses: actions/checkout@v4 | |
with: | |
repository: any-tdf/stdf | |
token: ${{ secrets.STDF_GITHUB_TOKEN }} | |
path: stdf | |
# 切换到 next 分支 | |
- name: Checkout next | |
run: | | |
git checkout next | |
# 读取 packages/rollup-plugin-stdf-icon 中的 package.json 文件,获取 version 的值 | |
- name: Read Icon version | |
run: | | |
version=$(cat packages/rollup-plugin-stdf-icon/package.json | grep -E '"version":' | awk -F'"' '{print $4}') | |
echo "version: $version" | |
# 初始化 stdf demo 仓库 | |
# 将 stdf/LICENSE 复制到 stdf/packages/stdf/LICENSE | |
# 将 stdf/README.md 复制到 stdf/packages/stdf/README.md | |
# 将上一步获取的 version 字段前面增加 ^ 号,将 packages/stdf/package.json 中的 file:../rollup-plugin-stdf-icon 替换为 ^version | |
- name: Init stdf demo | |
run: | | |
cp stdf/LICENSE stdf/packages/stdf/LICENSE | |
cp stdf/README.md stdf/packages/stdf/README.md | |
sed -i "s|file:../rollup-plugin-stdf-icon|^${version}|g" stdf/packages/stdf/package.json | |
cd stdf/packages/stdf | |
git init | |
git config --global user.name 'GitHub Actions' | |
git config --global user.email 'GitHub Actions' | |
git add . | |
git commit -m "Github Actions auto commit: update demo from stdf." | |
# 将修改内容推送到 git@github.com:any-tdf/next-demo-stdf.git 的 main 分支 | |
- name: Push to next-demo-stdf | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.STDF_GITHUB_TOKEN }} | |
branch: main | |
force: true | |
directory: stdf/packages/stdf | |
repository: any-tdf/next-demo-stdf |