Skip to content

Commit

Permalink
Move between two repositories more cleanly during patch (#2172)
Browse files Browse the repository at this point in the history
* fix: checkout multiple repos cleanly

* fix: ensure git apply exits cleanly
  • Loading branch information
JoshMock authored Mar 21, 2024
1 parent 8afdec0 commit 1d84468
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/serverless-patch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,21 @@ jobs:
with:
repository: elastic/elasticsearch-js
ref: '${{ github.event.pull_request.merge_commit_sha }}'
- name: Generate patch file
run: |
git format-patch -1 --stdout ${{ github.event.pull_request.merge_commit_sha }} > /tmp/patch.diff
path: elasticsearch-js
- uses: actions/checkout@v4
with:
repository: elastic/elasticsearch-serverless-js
ref: main
- name: Apply patch to serverless
path: elasticsearch-serverless-js
- name: Generate patch file
run: |
cd $GITHUB_WORKSPACE/elasticsearch-js
git format-patch -1 --stdout ${{ github.event.pull_request.merge_commit_sha }} > /tmp/patch.diff
- name: Apply patch file
run: |
cd $GITHUB_WORKSPACE/elasticsearch-serverless-js
git checkout -b apply-patch-${{ github.event.pull_request.id }}
git apply -C1 --recount --reject /tmp/patch.diff
git apply -C1 --recount --reject /tmp/patch.diff || exit 0
comment='Patch applied from elastic/elasticsearch-js#${{ github.event.pull_request.id }}'
for f in $(find . -name '*.rej'); do
comment="$comment\n\n## Rejected patch \`$f`\:\n\`\`\`\n$(cat $f)\n\`\`\`"
Expand Down

0 comments on commit 1d84468

Please sign in to comment.