-
Notifications
You must be signed in to change notification settings - Fork 31
50 lines (43 loc) · 1.45 KB
/
publish-and-pr.yml
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
41
42
43
44
45
46
47
48
49
50
name: 自动发布
on:
pull_request:
types:
- closed
branches:
- master
workflow_dispatch:
jobs:
publish-and-pr:
if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Run publish script
run: npm run publish
# 生成分支名称并存储为变量
- name: Generate branch name
id: branch_name
run: |
echo "branch_name=auto-publish-changes-$(date +%s)" >> $GITHUB_OUTPUT
# Configure Git for committing changes
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Push changes and create a PR
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
branch: ${{ steps.branch_name.outputs.branch_name }}
title: "Automated Changes After Publish"
body: |
This PR was created automatically after running the publish script on the master branch.
commit-message: "Automated changes after publish"
base: master