Skip to content

🐛 fix: remove nonexistent repos from CI #15

🐛 fix: remove nonexistent repos from CI

🐛 fix: remove nonexistent repos from CI #15

Workflow file for this run

name: CI/CD Build and Deploy
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: '20'
package-manager-cache: false
- name: Install dependencies
run: npm install --no-package-lock
- name: Build project
run: npm run build
- name: Prepare build branch
run: |
# 配置 git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# 创建临时目录
mkdir -p /tmp/build-output
# 复制必要的文件到临时目录
cp -r dist /tmp/build-output/
cp package.json /tmp/build-output/
cp README.md /tmp/build-output/
cp LICENSE /tmp/build-output/
# 修改 package.json 以移除 devDependencies 和构建脚本
cd /tmp/build-output
# 切换到 build 分支(孤儿分支)
cd $GITHUB_WORKSPACE
git checkout --orphan build
# 删除所有文件
git rm -rf .
# 复制构建产物
cp -r /tmp/build-output/* .
# 创建 .gitignore
echo "node_modules/" > .gitignore
# 提交更改
git add -A
git commit -m "Build output from ${{ github.sha }}" || echo "No changes to commit"
# 强制推送到 build 分支
git push origin build --force
- name: Trigger downstream repositories
env:
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
run: |
REPOS=(
"scratch-fuse/compiler"
"scratch-fuse/serializer"
"scratch-fuse/builtins"
)
for repo in "${REPOS[@]}"; do
echo "Triggering workflow for $repo..."
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GH_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${repo}/actions/workflows/ci.yml/dispatches" \
-d '{"ref":"main"}' \
&& echo "✓ Successfully triggered $repo" \
|| echo "✗ Failed to trigger $repo"
done