Skip to content

Commit

Permalink
feat(create-pr): add a script to trigger a pull request on the remote
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelAlphonso committed Jun 7, 2022
1 parent 66d879f commit 3016115
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions create-pr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

OWNER=locomotive-charcoal
REPO=charcoal
REF=$(git branch --show-current)
BASE=${1:-main}
USER=$(git config user.email)

echo "Preparing pull request form $REF to $BASE..."

HTTP_CODE=$(curl --write-out "%{http_code}\n" --output output.txt --silent \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$OWNER/$REPO/actions/workflows/create-pull-request.yaml/dispatches \
-d "{\"ref\":\"$REF\",\"inputs\":{\"base\":\"$BASE\",\"user_name\":\"$USER\"}}" \
-u github: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)

echo $HTTP_CODE

if [ 200 -gt $HTTP_CODE ] || [ $HTTP_CODE -gt 299 ]; then
echo "There was an error triggering the pull request."
exit 1
fi

echo "The pull request was successfully triggered."

exit 0

0 comments on commit 3016115

Please sign in to comment.