Skip to content

Commit d61d54a

Browse files
authored
Action to apply stack client patches to serverless (#2169)
* GitHub action for applying stack client patches to serverless * Drop unnecessary comment
1 parent d430aec commit d61d54a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Apply PR changes to serverless
3+
on:
4+
pull_request_target:
5+
types:
6+
- closed
7+
- labeled
8+
9+
jobs:
10+
backport:
11+
name: Backport
12+
runs-on: ubuntu-latest
13+
# Only react to merged PRs for security reasons.
14+
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
15+
if: >
16+
github.event.pull_request.merged
17+
&& (
18+
(
19+
github.event.action == 'closed'
20+
&& contains(github.event.pull_request.labels.*.name, 'apply-to-serverless')
21+
)
22+
||
23+
(
24+
github.event.action == 'labeled'
25+
&& github.event.label.name == 'apply-to-serverless'
26+
)
27+
)
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Generate patch file
31+
run: |
32+
git format-patch -1 --stdout ${{ github.event.pull_request.merge_commit_sha }} > /tmp/patch.diff
33+
- uses: actions/checkout@v4
34+
with:
35+
repository: elastic/elasticsearch-serverless-js
36+
ref: main
37+
- name: Apply patch to serverless
38+
run: |
39+
git checkout -b apply-patch-${{ github.event.pull_request.id }}
40+
git apply -C1 --recount --reject /tmp/patch.diff
41+
comment='Patch applied from elastic/elasticsearch-js#${{ github.event.pull_request.id }}'
42+
for f in $(find . -name '*.rej'); do
43+
comment="$comment\n\n## Rejected patch \`$f`\:\n\`\`\`\n$(cat $f)\n\`\`\`"
44+
done
45+
gh pr create -t "Apply PR changes from elastic/elasticsearch-js#${{ github.event.pull_request.id }}" --body "$comment"

0 commit comments

Comments
 (0)