-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (88 loc) · 3.39 KB
/
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
on: workflow_call
jobs:
release_pr:
name: Release Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: ${{ vars.NODE_VERSION }}
- name: Auth
uses: actions/create-github-app-token@v1
id: auth
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Set ENV variables
run: |
echo "REPO_NAME=${GITHUB_REPOSITORY#$GITHUB_REPOSITORY_OWNER/}" >> $GITHUB_ENV
echo "DATE=$(date +'%d.%m.%Y')" >> $GITHUB_ENV
- name: Changelog
run: |
git config --global user.email "sheep@taskany.org"
git config --global user.name "Taskany Sheep"
npx @taskany/release@latest
npm version $(cat version) --git-tag-version false
git checkout -b releases/$(cat version)
git add .
git commit -n -m "chore: release $(cat version)"
git push --no-verify origin releases/$(cat version)
- name: Pull Request
id: pr
env:
GH_TOKEN: ${{ steps.auth.outputs.token }}
run: |
pr_url=$(gh pr create --head $(git branch --show-current) --title "Release $(cat version)" --label release -F .release_bot/body)
echo "pr_url=${pr_url}" >> $GITHUB_OUTPUT
- name: Get commits
id: commit_messages
run: |
git checkout releases/$(cat version)
commits=$(git log $(git describe --tags --abbrev=0)..HEAD --no-merges --pretty=format:%H)
echo "commits=${commits//$'\n'/','}" >> $GITHUB_OUTPUT
- name: Get JIRA tasks
id: jira_tasks
uses: actions/github-script@v7
env:
COMMIT_MESSAGES: ${{ steps.commit_messages.outputs.commits }}
with:
script: |
const hashes = process.env.COMMIT_MESSAGES.split(',');
const tasks = [];
for (const hash of hashes) {
try {
const { data } = await github.rest.repos.getCommit({
owner: `${{ github.repository_owner }}`,
repo: process.env.REPO_NAME,
ref: hash
});
const jiraIdMatch = data.commit.message.toLocaleLowerCase().match(/${{ secrets.JIRA_KEY }}-\d+/i);
const id = jiraIdMatch ? jiraIdMatch[0] : null;
if (id) {
tasks.push(id);
}
} catch (error) {
console.error(`Error fetching PR #${hash}:`, error);
}
}
return tasks;
- name: Send MM
uses: mattermost/action-mattermost-notify@master
if: ${{ vars.RELEASE_PROJECT_NAME }}
with:
MATTERMOST_WEBHOOK_URL: ${{ secrets.WEBHOOKS_RELEASE_LF_MM }}
TEXT: |-
{
"name": "${{ vars.RELEASE_PROJECT_NAME }}",
"version": "Release ${{ env.DATE }}",
"applicationType": "web",
"hotfix": false,
"authorMmUser": "assabotovich",
"configurationElement": "${{ secrets.CE }}",
"distributionLink": "${{ steps.pr.outputs.pr_url }}",
"tasks": ${{ steps.jira_tasks.outputs.result }},
"jiraProject": "${{ secrets.RELEASE_JIRA_KEY }}"
}