Skip to content

Commit

Permalink
Trying to implement deploy to production. (#1257)
Browse files Browse the repository at this point in the history
* Trying to implement deploy to production.

* Trying to add conditional deployment in travis.yml and changed the deployment script.

* Trying to add conditional deployment in travis.yml and changed the deployment script.

* Trying to fix the deployment script.

* Installing sshpass.

* Moving the install of sshpass.

* Adding branch for master in travis.yml and fixing tar.command in deploy.sh.

* Added variables for branches in travis.yml and deploy.sh.

* Tweaked deployment script and completed the flow to publish the branched build in a testfolder.

* Commented after_deploy, to prevent mishaps.

* Cleaning up travis.yml.

* Still trying to fix travis.yml, variable seems to flush.

* Still trying to fix travis.yml, variable seems to flush.

* Travis is not a friend of mine.

* Travis is not a friend of mine v2.

* Travis is not a friend of mine v2.

* Fixing the deployment, maybe.

* Cleaning up.

* Added some intelligence in deployment script, to filter master from other branches.

* Fixing own stupidity.

* Fixing statement.

* Obvious mistakes were made.

* Yes, but no, but yes?

* Added login for docker, improved logic in deploy.sh.
  • Loading branch information
Myrdrahl authored and bjornreppen committed Apr 8, 2019
1 parent 19fc579 commit 662983f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,30 @@ directories:
script:
- yarn test
- yarn build
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
before_deploy:
- git tag "$(date +'%Y%m%d-%H%M%S')-$(git log --format=%h -1)"
- tar --directory=build -zcf bundle.tar.gz .
deploy:
provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundle.tar.gz
on:
repo: Artsdatabanken/nin-kart-frontend
skip_cleanup: true
after_deploy: ./slack.sh ops "deploy nin-innsyn"
- provider: releases
api_key: $GITHUB_TOKEN
file_glob: true
file: bundle.tar.gz
on:
branch: master
repo: Artsdatabanken/nin-kart-frontend
skip_cleanup: true
after_success:
- npm run report-coverage
- ./deploy.sh $BRANCH ops "deploy nin-innsyn-test" $DOCKER_USERNAME $DOCKER_PASSWORD
notifications:
slack:
on_success: change
on_failure: change
before_install:
- yarn global add greenkeeper-lockfile@1
- export PATH=$PATH:`yarn global bin`
- sudo apt-get install -y sshpass
before_script: greenkeeper-lockfile-update
after_script: greenkeeper-lockfile-upload
17 changes: 14 additions & 3 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
echo $1 $2
docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
if [ "$1" != "master" ]
then
echo "Zipping files"
#echo $1
tar --directory=build -zcf $1.tar.gz .
echo "Sending files to prod"
sshpass -p $scp_pass scp -o StrictHostKeyChecking=no $1.tar.gz $scp_user@158.38.128.51:/tmp/test
sleep 30
curl -X POST --data-urlencode "payload={\"channel\": \"$2\", \"username\": \"travis not the band\", \"text\": \"$3\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/$SLACK_TOKEN
else
#docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
docker login -u="$4" -p="$5"
docker build -t artsdatabanken/nin-innsyn:latest .
docker images
docker push artsdatabanken/nin-innsyn:latest
docker push artsdatabanken/nin-innsyn:latest
fi
2 changes: 1 addition & 1 deletion slack.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
if [ "$TRAVIS_BRANCH" == "master" ]; then
if [ "$BRANCH" == "master" ]; then
curl -X POST --data-urlencode "payload={\"channel\": \"$1\", \"username\": \"travis not the band\", \"text\": \"$2\", \"icon_emoji\": \":ghost:\"}" https://hooks.slack.com/services/$SLACK_TOKEN
fi

0 comments on commit 662983f

Please sign in to comment.