-
-
Notifications
You must be signed in to change notification settings - Fork 216
72 lines (64 loc) · 2.6 KB
/
auto-changeset.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: Add changeset automatically
on:
pull_request_target:
types:
- opened
- edited
jobs:
auto-changeset:
if: |
startsWith(github.repository, 'asyncapi/') &&
( startsWith(github.event.pull_request.title, 'fix:') ||
startsWith(github.event.pull_request.title, 'feat:') ||
startsWith(github.event.pull_request.title, 'fix!:') ||
startsWith(github.event.pull_request.title, 'feat!:')
)
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Checkout PR
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Determine release type
id: determine_release_type
uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title;
const releaseType = title.split(':')[0];
switch (releaseType) {
case 'fix':
return 'patch';
case 'feat':
return 'minor';
case 'fix!':
return 'major';
case 'feat!':
return 'major';
default:
return 'patch';
}
- name: Create changeset file
run: "echo -e '---\n'@asyncapi/cli': ${{ steps.determine_release_type.outputs.result }}\n---\n\n ${{ github.event.pull_request.title }}\n' > .changeset/${{ github.event.pull_request.number }}.md"
- name: Commit changeset file
run: |
git config --global user.name asyncapi-bot
git config --global user.email [email protected]
git add .changeset/${{ github.event.pull_request.number }}.md
git commit -m "chore: add changeset for PR #${{ github.event.pull_request.number }}"
- name: Push changeset file
run: git push https://${{ secrets.GH_TOKEN }}@github.com/${{ github.event.pull_request.head.repo.full_name }} HEAD:${{ github.event.pull_request.head.ref }}
# Only, on failure, send a message on the 94_bot-failing-ci slack channel
- if: failure()
name: Report workflow run status to Slack
uses: 8398a7/action-slack@fbd6aa58ba854a740e11a35d0df80cb5d12101d8 #using https://github.com/8398a7/action-slack/releases/tag/v3.15.1
with:
status: ${{ job.status }}
fields: repo,action,workflow
text: 'AsyncAPI CLI release to Chocolatey failed'
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_CI_FAIL_NOTIFY }}