-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(create-pr): add a script to trigger a pull request on the remote
- Loading branch information
1 parent
66d879f
commit 3016115
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |