Skip to content

Commit

Permalink
Fi 2432 Sync Inferno Template (#439)
Browse files Browse the repository at this point in the history
* 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
Shaumik-Ashraf authored Apr 5, 2024
1 parent 4e25be1 commit 3047f95
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
/lib/inferno/public/*.LICENSE.txt
/lib/inferno/public/*.png
!/lib/inferno/public/logo*.png
/tmp
!/tmp
/tmp/*
!/tmp/.keep
.env.local
.env.*.local
**/.DS_Store
Expand Down
1 change: 1 addition & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ AllCops:
- 'Gemfile'
- 'vendor/**/*'
- 'lib/inferno/db/schema.rb'
- 'tmp/**/*'

Layout/LineLength:
Max: 120
Expand Down
55 changes: 55 additions & 0 deletions scripts/publish_template
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
Empty file added tmp/.keep
Empty file.

0 comments on commit 3047f95

Please sign in to comment.