-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fi 2432 Sync Inferno Template (#439)
* add draft publish_template.sh * add Inferno version command * add Inferno version rspec * rubocop conformance * remove force push * test script * add tmp folder to git, but ignore files in tmp * make script use tmp folder and push to branch * make publish_template rename tmp/inferno-template instead of removing it * clean script * config rubocop to ignore tmp/ * fix typo * add github access token env option for publish_template script to put up a PR * remove +x from publish_template * improve publish_template.sh end messages * fix comments * mv publish_template.sh scripts/publish_template * debug
- Loading branch information
1 parent
4e25be1
commit 3047f95
Showing
4 changed files
with
59 additions
and
1 deletion.
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
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
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,55 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Push a new Inferno version to inferno-template GitHub Repository via SSH. | ||
# | ||
# USAGE: | ||
# ./publish_template | ||
# OR | ||
# ./publish_template [github/ssh/url] | ||
# OR | ||
# GITHUB_ACCESS_TOKEN="PUT_YOUR_TOKEN_HERE" ./publish_template | ||
|
||
set -e | ||
|
||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
REPO_URL=${1:-git@github.com:inferno-framework/inferno-template.git} | ||
VERSION=$(bundle exec $SCRIPT_DIR/../bin/inferno version) | ||
TITLE="Update $VERSION" | ||
BRANCH=$(echo $TITLE | tr ' [:upper:]' '-[:lower:]') | ||
|
||
cd "$SCRIPT_DIR/../tmp" | ||
git clone $REPO_URL ./inferno-template | ||
git -C ./inferno-template branch $BRANCH | ||
git -C ./inferno-template checkout $BRANCH | ||
|
||
rm -f ./inferno-template/Gemfile.lock | ||
|
||
bundle exec ../bin/inferno new inferno-template --author "Inferno Template" --force | ||
|
||
git -C ./inferno-template add --all | ||
git -C ./inferno-template commit --message "Update to $VERSION" | ||
git -C ./inferno-template push --set-upstream origin $BRANCH | ||
mv ./inferno-template "./inferno-template-$BRANCH" | ||
cd - | ||
|
||
if [[ ! -z "${GITHUB_ACCESS_TOKEN}" ]]; then | ||
ENDPOINT=${REPO_URL%.git} | ||
ENDPOINT=${ENDPOINT#git@github.com:} | ||
|
||
curl \ | ||
--request POST \ | ||
--header "Content-type: application/json" \ | ||
--header "Authorization: Bearer ${GITHUB_ACCESS_TOKEN}" \ | ||
--header "X-GitHub-Api-Version: 2022-11-28" \ | ||
--data "{ \"title\":\"$TITLE\", \"head\":\"${BRANCH}\", \"base\":\"main\"}" \ | ||
"https://api.github.com/repos/$ENDPOINT/pulls" | ||
echo "Put up pull request: $TITLE. Please merge it to main." | ||
echo "You can troubleshoot changes locally at tmp/inferno-template-$BRANCH" | ||
else | ||
echo "No GITHUB_ACCESS_TOKEN found, skipping pull request" | ||
echo "Committed changes to active branch $BRANCH" | ||
echo "Pushed changes to remote branch on origin" | ||
echo "You can troubleshoot changes locally at tmp/inferno-template-$BRANCH" | ||
echo "Please put up a pull request manually" | ||
fi |