Initial commit

contains:
* Actual template
* Example function
* Tests
* Integration test (make file)
* Integration tests (deployed as lambda)
* drone CI and CI scripts
This commit is contained in:
Rioting Pacifist
2020-03-16 15:39:43 +00:00
commit b9b3bf572f
18 changed files with 527 additions and 0 deletions

23
ci/cleanup.sh Normal file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Delete a deployed environment after a merge
# checks parent commits for environment/<env>.env
PROTECTED=master
function try_and_delete_environment () {
if [ -f "environments/${1}.env" ]; then
make delete env="${1}"
exit 0
fi
}
MERGED_ENVIRONMENT="${DRONE_SOURCE_BRANCH##*/}"
if [[ ! "$MERGED_ENVIRONMENT" =~ $PROTECTED ]]; then
try_and_delete_environment "$MERGED_ENVIRONMENT"
echo "Checking out parent commits for env file"
for PARENT in $(git log --pretty=%P -n 1 | tac -s ' '); do
git checkout "$PARENT"
try_and_delete_environment "$MERGED_ENVIRONMENT"
done
fi

17
ci/deploy.sh Normal file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
PROTECTED=master
ENVIRONMENT="${DRONE_BRANCH##*/}"
[ -z "$ENVIRONMENT" ] && ENVIRONMENT="$DRONE_TAG"
if [[ "$ENVIRONMENT" =~ $PROTECTED ]] && [ "$ENVIRONMENT" != "$DRONE_BRANCH" ] ; then
echo "Can only deploy to $PROTECTED from named branches"
unset ENVIRONMENT
fi
if [ -f "environments/${ENVIRONMENT}.env" ] ; then
make all "env=${ENVIRONMENT}"
else
make all env=ci
make delete env=ci
fi