This repository has been archived by the owner on Nov 7, 2023. It is now read-only.
-
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.
build(COOKIECUTTER): tooling to update existing roles
- Loading branch information
1 parent
5d0db24
commit 8cfd0bf
Showing
3 changed files
with
78 additions
and
8 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
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 |
---|---|---|
@@ -1,10 +1,33 @@ | ||
#!/bin/bash | ||
|
||
git init | ||
git checkout -b master | ||
git stage . | ||
git commit -m "build(Cookiecutter): Initial Generation" | ||
git symbolic-ref HEAD refs/heads/master | ||
git tag v0.0.0 | ||
mkdir -p files templates | ||
poetry install | ||
initialize_git() { | ||
git init | ||
git checkout -b master | ||
git stage . | ||
git commit -m "build(COOKIECUTTER): initial generation" | ||
git symbolic-ref HEAD refs/heads/master | ||
git tag v0.0.0 | ||
git checkout -b production | ||
git checkout master | ||
mkdir -p files templates | ||
} | ||
|
||
initialize_poetry() { | ||
if [[ -z "$(poetry env list)" ]]; then | ||
poetry install | ||
fi | ||
} | ||
|
||
update_template_values() { | ||
# Compatible with Linux and BSD sed | ||
sed -i.bak 's/ansible-workbench\//https:\/\/github.com\/Shared-Vision-Solutions\/ansible-workbench.git/' .cookiecutter/cookiecutter.json | ||
rm .cookiecutter/cookiecutter.json.bak | ||
} | ||
|
||
main() { | ||
update_template_values | ||
initialize_git | ||
initialize_poetry | ||
} | ||
|
||
main |
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,45 @@ | ||
#!/bin/bash | ||
|
||
# This script helps automate the process of updating a role that has already been created. | ||
# A branch "update-template" is created, with the changes required to update the workflow. | ||
# Use git cherry-pick (or create a patch from this change set) to update your ansible role. | ||
|
||
# Requires: https://pypi.org/project/cookiecutter-project-upgrader/ | ||
|
||
error() { | ||
echo "USAGE: ./update.sh [ROLE FOLDER] [TEMPLATE TAG or BRANCH]" | ||
exit 127 | ||
} | ||
|
||
[[ -z $2 ]] && error | ||
[[ -z $1 ]] && error | ||
|
||
main() { | ||
|
||
pushd "$1" || error | ||
cookiecutter_project_upgrader \ | ||
-c .cookiecutter/cookiecutter.json \ | ||
-b "update-template" \ | ||
-u "$2" \ | ||
-f https://github.com/shared-vision-solutions/ansible-workbench.git \ | ||
-e "defaults" \ | ||
-e "handlers" \ | ||
-e "meta" \ | ||
-e "molecule" \ | ||
-e "tasks" \ | ||
-e "tests" \ | ||
-e "vars" \ | ||
-e ".ansible-lint" \ | ||
-e ".gitignore" \ | ||
-e "pyproject.toml" \ | ||
-e "requirements.yml" \ | ||
-e ".travis.yml" \ | ||
-e "LICENSE" \ | ||
-e "README.md" | ||
|
||
git checkout update-template | ||
popd || true | ||
|
||
} | ||
|
||
main "$@" |