-
Notifications
You must be signed in to change notification settings - Fork 19
72 lines (60 loc) · 2.99 KB
/
create-release-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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Create Release PR
on:
workflow_dispatch:
inputs:
version:
description: 'i.e. v1.14.1'
required: true
env:
git-user: kubeshop-bot
git-email: [email protected]
base-branch: main
source-branch: develop
jobs:
create-pr:
runs-on: ubuntu-latest
steps:
- name: Sanitize version
run: |
VERSION=${{ github.event.inputs.version }}
echo "VERSION=$(echo "$VERSION" | sed "s/^v//")" >> "$GITHUB_ENV"
- name: Check out GitHub repo
uses: actions/checkout@v4
with:
ref: ${{ env.source-branch }}
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "${{ env.git-user }}"
git config user.email "${{ env.git-email }}"
- name: Create release branch
run: git checkout -B "release/v$VERSION" && git merge origin/${{ env.base-branch }}
- name: Push release branch
run: git push -f origin "release/v$VERSION"
- name: Build log
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "CHANGELOG<<$EOF" >> "$GITHUB_ENV"
echo "$(git --no-pager log "origin/main..HEAD" --pretty='format:|[**`%h`**](https://github.com/kubeshop/testkube-dashboard/commit/%h) | %s |' 2>&1 | sed 's/ (#\([0-9]*\))[^"]/|([#\1](https:\/\/github.com\/kubeshop\/testkube-dashboard\/pull\/\1))/g' | sed 's/Merge pull request #\([0-9]*\)\(.*\)/Merge pull request #\1\2 | ([#\1](https:\/\/github.com\/kubeshop\/testkube-dashboard\/pull\/\1))/')" >> "$GITHUB_ENV"
echo "$EOF" >> "$GITHUB_ENV"
echo "FULL_CHANGELOG<<$EOF" >> "$GITHUB_ENV"
echo "$(git --no-pager log "origin/main..HEAD" --pretty='format:|[**`%h`**](https://github.com/kubeshop/testkube-dashboard/commit/%h)| %ci | %an | %s |' 2>&1 | sed 's/ (#\([0-9]*\))[^"]/|([#\1](https:\/\/github.com\/kubeshop\/testkube-dashboard\/pull\/\1))/g' | sed 's/Merge pull request #\([0-9]*\)\(.*\)/Merge pull request #\1\2 | ([#\1](https:\/\/github.com\/kubeshop\/testkube-dashboard\/pull\/\1))/')" >> "$GITHUB_ENV"
echo "$EOF" >> "$GITHUB_ENV"
- name: Create PR
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "> #### Don't forget to avoid 'Squash and Merge' - use with merge commit instead!" > message
echo "### Changelog" >> message
echo "| Commit | Description | PR |" >> message
echo "|-|-|-|" >> message
echo "$CHANGELOG" >> message
echo "" >> message
echo "<details>" >> message
echo " <summary>Details</summary>" >> message
echo "" >> message
echo " | Commit | Date | Author | Description | PR |" >> message
echo " |-|-|-|-|-|" >> message
echo " $FULL_CHANGELOG" >> message
echo "</details>" >> message
gh pr create --assignee "${{ github.triggering_actor }}" --title "Release v$VERSION" --base "${{ env.base-branch }}" --head "release/v$VERSION" --body "$(cat message)"