-
Notifications
You must be signed in to change notification settings - Fork 1
40 lines (33 loc) · 1.01 KB
/
create-dev-branch.yaml
File metadata and controls
40 lines (33 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: 创建开发分支
on:
workflow_dispatch:
inputs:
message:
description: '需求(例: userlogin)'
required: true
permissions:
contents: write
jobs:
create-dev-branch:
runs-on: macos-latest
steps:
- name: 检出代码库
uses: actions/checkout@v4
- name: 检查分支
if: github.ref != 'refs/heads/main'
run: |
echo "错误: 该工作流只能在 main 分支上运行。"
exit 1
- name: 根据时间戳生成分支名称
id: generate-branch
run: |
DATE=$(date -u +'%Y%m%d')
BRANCH_NAME="dev-$DATE-${{ github.event.inputs.message }}"
echo "Generated branch name: $BRANCH_NAME"
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: 创建新分支
run: |
NEW_BRANCH=${{ steps.generate-branch.outputs.branch_name }}
echo "Creating branch: $NEW_BRANCH"
git checkout -b $NEW_BRANCH
git push origin $NEW_BRANCH