Skip to content

Merge pull request #16 from qunqichen/qunqichen/patch-36724 #20

Merge pull request #16 from qunqichen/qunqichen/patch-36724

Merge pull request #16 from qunqichen/qunqichen/patch-36724 #20

name: Merge stackblitz branch to main
on:
push:
branches:
- stackblitz
permissions:
contents: write
pull-requests: write
jobs:
merge_branch:
if: ${{ github.actor != 'github-actions[bot]' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: 获取所有分支
run: |
git fetch --all
- name: 创建新分支 'stackblitz-pr' 基于 'main'
run: |
git push origin --delete stackblitz-pr || true
git checkout -b stackblitz-pr
- name: 设置 Git 用户信息
run: |
git config user.name "github-actions[bot]"
git config user.email "[email protected]"
- name: 从 'stackblitz' 分支 cherry-pick 提交(排除指定提交)
run: |
# 获取 'stackblitz' 分支相对于 'main' 的提交ID,按时间顺序从旧到新排序
CHERRY_COMMITS=$(git log --reverse --no-merges --pretty=format:"%H" origin/main..origin/stackblitz | grep -v 6c76e6dbf89a0c62bfdd63c79397c051d55148e2)
echo "CHERRY_COMMITS: $CHERRY_COMMITS"
for commit in $CHERRY_COMMITS; do
git cherry-pick $commit || git cherry-pick --skip
done
- name: 推送新分支
run: |
git push origin stackblitz-pr
- name: Create pull request
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Merge stackblitz branch to main',
head: 'stackblitz-pr',
base: 'main',
body: '该 PR 由 GitHub Actions 自动创建,用于合并 stackblitz 分支到 main 分支,请检查是否正确。',
})