refactor travis encrypt to manual process before push

This commit is contained in:
Lachlan Kermode
2018-12-18 15:54:44 +00:00
parent 651f768c5b
commit e573348679
3 changed files with 18 additions and 7 deletions

View File

@@ -9,12 +9,12 @@
"start": "node dist",
"lint": "standard \"src/**/*.js\" \"test/**/*.js\"",
"test-watch": "ava --watch",
"test": "ava --verbose"
"test": "ava --verbose",
"travis-encrypt": "./scripts/encrypt.sh"
},
"husky": {
"hooks": {
"pre-commit": "sh ./scripts/encrypt.sh",
"pre-push": "yarn lint && yarn test"
"pre-push": "./scripts/check-branch.sh && yarn lint && yarn test"
}
},
"repository": {

11
scripts/check-branch.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
ENCRYPT_MESSAGE="\nThe .env.enc file has not changed its contents from the version on origin/develop.\nTo ensure that tests pass in Travis, you need to encrypt the contents of .env before pushing to the remote, so that the Travis server can use your service account credentials.\nEnsure that the Travis CLI is installed on your local, run\n\n\tnpm run travis-encrypt\n\nand then push to the remote again.\nIf you don't care whether your build passes on Travis, you can run:\n\n\tgit push --no-verify\n\nand bypass this check.\n\n"
# check whether .env.enc has changed
if [ -z "`git diff origin/develop -- .env.enc`" ]; then
echo $ENCRYPT_MESSAGE
exit 1
fi

View File

@@ -2,10 +2,10 @@
echo "Encrypting .env file for Travis..."
# confirm that the user has the core repo as origin, and is therefore a maintainer
if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then
echo "Travis encryption not required for satellite contributors, continuing.."
exit 0
fi
# if [ -z `git config --get remote.origin.url | grep "forensic-architecture/datasheet-server"` ]; then
# echo "Travis encryption not required for satellite contributors, continuing.."
# exit 0
# fi
# confirm travis is installed
if [ ! hash travis 2>/dev/null ]; then