-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (58 loc) · 2.25 KB
/
Copy pathrelease-branch.yaml
File metadata and controls
67 lines (58 loc) · 2.25 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Create Release Branch and PR
on:
workflow_dispatch:
inputs:
release_type:
description: 'Release type (minor, patch, major)'
required: false
default: 'minor'
permissions:
contents: write
pull-requests: write
jobs:
create_release_branch:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
fetch-depth: 0
- name: Install Task
run: |
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
- name: Get last commit author
id: last_author
run: |
AUTHOR=$(git log -1 --pretty=format:'%ae')
echo "author_email=$AUTHOR" >> $GITHUB_OUTPUT
- name: Create release branch
run: |
BRANCH="release-$(date +%Y%m%d%H%M%S)"
git checkout -b "$BRANCH"
echo "RELEASE_BRANCH=$BRANCH" >> $GITHUB_ENV
- name: Run release task and commit changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
task release:${{ github.event.inputs.release_type }}
git push origin "$RELEASE_BRANCH"
- name: Find GitHub username by email
id: find_user
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
script: |
const email = process.env['AUTHOR_EMAIL'] || '${{ steps.last_author.outputs.author_email }}';
const { data: users } = await github.rest.search.users({ q: `${email} in:email` });
if (users.items.length > 0) {
core.setOutput('username', users.items[0].login);
} else {
core.setOutput('username', '');
}
- name: Create Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ env.RELEASE_BRANCH }}
title: "Release: ${{ github.event.inputs.release_type }}"
body: "Automated release PR for ${{ github.event.inputs.release_type }}"
assignees: ${{ steps.find_user.outputs.username }}