Skip to content

Commit 0191756

Browse files
jsvdmashhurs
andauthored
Add Github Action workflow for release notes generation (#14236)
Co-authored-by: Mashhur <[email protected]>
1 parent 805bf06 commit 0191756

File tree

2 files changed

+45
-5
lines changed

2 files changed

+45
-5
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Release Notes Draft generator
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
type: string
8+
required: true
9+
default: "8.2"
10+
last_release:
11+
type: string
12+
required: true
13+
default: "8.2.2"
14+
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
issues: write
20+
21+
jobs:
22+
main:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v3
26+
with:
27+
fetch-depth: 0
28+
- name: Set up Ruby
29+
uses: ruby/setup-ruby@v1
30+
with:
31+
ruby-version: '3.0'
32+
- run: git config --global user.email "[email protected]"
33+
- run: git config --global user.name "logstashmachine"
34+
- name: Create Release Notes Draft
35+
run: ./tools/release/generate_release_notes.rb ${{ github.event.inputs.branch }} ${{ github.event.inputs.last_release }} ${{ github.actor }} ${{ secrets.GITHUB_TOKEN }}

tools/release/generate_release_notes.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
RELEASE_NOTES_PATH = "docs/static/releasenotes.asciidoc"
3131
release_branch = ARGV[0]
3232
previous_release_tag = ARGV[1]
33+
user = ARGV[2]
34+
token = ARGV[3]
3335
report = []
3436

3537
`git checkout #{release_branch}`
@@ -118,12 +120,15 @@
118120
`git checkout -b #{branch_name}`
119121
`git commit docs/static/releasenotes.asciidoc -m "Update release notes for #{current_release}"`
120122

123+
121124
puts "Pushing commit.."
122-
`git remote add upstream git@github.com:elastic/logstash.git`
123-
`git push upstream #{branch_name}`
125+
`git remote set-url origin https://x-access-token:#{token}@github.com/elastic/logstash.git`
126+
`git push origin #{branch_name}`
124127

125128
puts "Creating Pull Request"
126-
pr_title = "Release notes draft for #{current_release}"
127-
`curl -H "Authorization: token #{ENV['GITHUB_TOKEN']}" -d '{"title":"#{pr_title}","base":"#{ENV['branch_specifier']}", "head":"#{branch_name}"}' https://api.github.com/repos/elastic/logstash/pulls`
128-
129+
pr_title = "Release notes for #{current_release}"
130+
result = `curl -H "Authorization: token #{token}" -d '{"title":"#{pr_title}","base":"#{release_branch}", "head":"#{branch_name}", "draft": true}' https://api.github.com/repos/elastic/logstash/pulls`
131+
puts result
132+
pr_number = JSON.parse(result)["number"]
133+
puts `curl -X POST -H "Accept: application/vnd.github.v3+json" -H "Authorization: token #{token}" https://api.github.com/repos/elastic/logstash/issues/#{pr_number}/assignees -d '{"assignees":["#{user}"]}'`
129134
puts "Done"

0 commit comments

Comments
 (0)