Refactor patch action to use create-pull-request action (#2186)
This commit is contained in:
28
.github/workflows/serverless-patch.sh
vendored
28
.github/workflows/serverless-patch.sh
vendored
@ -15,31 +15,25 @@ cd "$GITHUB_WORKSPACE/serverless"
|
|||||||
git checkout -b "apply-patch-$pull_request_id"
|
git checkout -b "apply-patch-$pull_request_id"
|
||||||
git am -C1 --reject /tmp/patch.diff || git am --quit
|
git am -C1 --reject /tmp/patch.diff || git am --quit
|
||||||
|
|
||||||
# commit changes, ignoring rejects
|
# generate PR body comment
|
||||||
git add -A
|
|
||||||
git reset -- **/*.rej
|
|
||||||
git commit -m "Apply changes from $pr_shortcode"
|
|
||||||
|
|
||||||
comment="Patch applied from $pr_shortcode"
|
comment="Patch applied from $pr_shortcode"
|
||||||
|
|
||||||
# enumerate rejected patches in PR comment
|
# enumerate rejected patches in PR comment
|
||||||
tick='\`' # just trying to satisfy shellcheck here
|
has_rejects='false'
|
||||||
has_rejects=''
|
|
||||||
for f in ./**/*.rej; do
|
for f in ./**/*.rej; do
|
||||||
has_rejects='--draft'
|
has_rejects='true'
|
||||||
comment="$comment
|
comment="$comment
|
||||||
|
|
||||||
## Rejected patch $tick$f$tick must be resolved:
|
## Rejected patch \`$f\` must be resolved:
|
||||||
|
|
||||||
$tick$tick$tick
|
\`\`\`diff
|
||||||
$(cat "$f")
|
$(cat "$f")
|
||||||
$tick$tick$tick
|
\`\`\`
|
||||||
"
|
"
|
||||||
done
|
done
|
||||||
|
|
||||||
# open a PR
|
# send data to output parameters
|
||||||
gh pr create \
|
{
|
||||||
--repo elastic/elasticsearch-serverless-js \
|
echo "PR_BODY='$comment'"
|
||||||
-t "Apply PR changes from $pr_shortcode" \
|
echo "PR_DRAFT=$has_rejects"
|
||||||
--body "$comment" \
|
} >> "$GITHUB_OUTPUT"
|
||||||
"$has_rejects"
|
|
||||||
|
|||||||
17
.github/workflows/serverless-patch.yml
vendored
17
.github/workflows/serverless-patch.yml
vendored
@ -37,11 +37,16 @@ jobs:
|
|||||||
repository: elastic/elasticsearch-serverless-js
|
repository: elastic/elasticsearch-serverless-js
|
||||||
ref: main
|
ref: main
|
||||||
path: serverless
|
path: serverless
|
||||||
- name: Set Git user
|
|
||||||
run: |
|
|
||||||
git config --global user.name "Elastic Machine"
|
|
||||||
git config --global user.email "elasticmachine@users.noreply.github.com"
|
|
||||||
- name: Apply patch from stack to serverless
|
- name: Apply patch from stack to serverless
|
||||||
env:
|
id: apply-patch
|
||||||
GH_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
|
||||||
run: $GITHUB_WORKSPACE/stack/.github/workflows/serverless-patch.sh
|
run: $GITHUB_WORKSPACE/stack/.github/workflows/serverless-patch.sh
|
||||||
|
- uses: peter-evans/create-pull-request@v6
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
path: $GITHUB_WORKSPACE/serverless
|
||||||
|
title: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
|
||||||
|
commit-message: 'Apply patch from elastic/elasticsearch-js#${{ github.event.pull_request.number }}'
|
||||||
|
branch-suffix: short-commit-hash
|
||||||
|
body: '${{ steps.apply-patch.outputs.PR_BODY }}'
|
||||||
|
draft: '${{ steps.apply-patch.outputs.PR_DRAFT }}'
|
||||||
|
add-paths: ':!*.rej'
|
||||||
|
|||||||
Reference in New Issue
Block a user