Move between two repositories more cleanly during patch (#2172)

* fix: checkout multiple repos cleanly

* fix: ensure git apply exits cleanly
This commit is contained in:
Josh Mock
2024-03-21 16:33:43 -05:00
committed by GitHub
parent 8afdec052a
commit 1d84468762

View File

@ -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\`\`\`"