Skip to content

Commit

Permalink
Merge pull request #7 from gnosis/feature/add-travis-ci
Browse files Browse the repository at this point in the history
Add travis CI config and scripts
  • Loading branch information
giacomolicari authored Apr 27, 2020
2 parents 523191b + 1109436 commit dfaa31b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
if: (branch = master) OR (branch = development) OR (tag IS present)
language: node_js
node_js: '12'
before_install:
- yarn install
# Needed to deploy pull request and releases
- pip install awscli --upgrade --user
cache:
yarn: true
script: |
echo "Skip tests" # no test cases for the project
if [ -n "$TRAVIS_TAG" ]
then
# build project for NPM publishing -> content goes to /dist
echo "Build NPM package"
yarn build
cd dist/
# https://classic.yarnpkg.com/en/docs/cli/pack/
yarn pack --filename safe-apps-sdk-$TRAVIS_TAG.tgz
cd ..
else
echo "No tagged commit, won't build NPM lib"
fi
deploy:
# Prepare production env deployment, no development deploy since the app
# is a npm library
- provider: s3
bucket: $STAGING_BUCKET_NAME
access_key_id: $AWS_ACCESS_KEY_ID
secret_access_key: $AWS_SECRET_ACCESS_KEY
skip_cleanup: true
local_dir: dist
upload-dir: releases/$TRAVIS_TAG
region: eu-central-1
on:
tags: true

- provider: script
script: bash travis/prepare_production_deployment.sh
on:
tags: true
18 changes: 18 additions & 0 deletions travis/prepare_production_deployment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -ev

# Only:
# - Tagged commits
# - Security env variables are available.
if [ -n "$TRAVIS_TAG" ] && [ -n "$PROD_DEPLOYMENT_HOOK_TOKEN" ] && [ -n "$PROD_DEPLOYMENT_HOOK_URL" ]
then
# Call Devops Releases Handler CI
curl --silent --output /dev/null --write-out "%{http_code}" -X POST \
-F token="$PROD_DEPLOYMENT_HOOK_TOKEN" \
-F ref=master \
-F "variables[TRIGGER_RELEASE_COMMIT_TAG]=$TRAVIS_TAG" \
$PROD_DEPLOYMENT_HOOK_URL
else
echo "[ERROR] Production deployment could not be prepared"
fi

0 comments on commit dfaa31b

Please sign in to comment.