Skip to content

merge-branch

merge-branch #277

Workflow file for this run

name: merge-branch
on:
schedule:
- cron: '0 0 * * *'
push:
branches:
- pre-merge/*
jobs:
generate:
permissions: write-all
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout Repository
uses: actions/checkout@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Branch
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
script: |
const { owner, repo } = context.repo
const option = { owner, repo }
const { data: branchData } = await github.rest.repos.listBranches({ ...option })
branchData.forEach(async ({ name }) => {
if (name.includes('pre-merge/')) {
const { data: prData } = await github.rest.pulls.create({ ...option, title: '自动创建 PR', head: `biaov:${name}`, base: 'main', body: '自动创建 PR' })
await github.rest.pulls.merge({ ...option, pull_number: prData.number })
}
})