diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a7ad18b..5170d27 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,5 +18,4 @@ jobs: key: ${{ secrets.SSH_KEY }} script: | cd services/github-contributions - chmod +x scripts/deploy.sh ./scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh old mode 100644 new mode 100755 index 45e9cf0..e280a20 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -4,7 +4,7 @@ processName="github-contributions" -# exit when any command fails +# Exit when any command fails set -e git reset --hard --quiet @@ -12,6 +12,12 @@ git reset --hard --quiet echo "Pulling from origin" git pull --quiet +# Ensure that npm can be found by GitHub actions +# See: https://gist.github.com/danielwetan/4f4db933531db5dd1af2e69ec8d54d8a?permalink_comment_id=4057972 +echo "Setting up NVM" +export NVM_DIR=~/.nvm +source ~/.nvm/nvm.sh + export NODE_ENV=production echo "Installing dependencies" @@ -21,7 +27,7 @@ echo "Building" npm run build echo "Killing old instance" -# deletion is allowed to fail, since the process might not have been running previously +# Deletion is allowed to fail, since the process might not have been running previously pm2 delete $processName --silent || true echo "Starting new instance"