Skip to content

Instantly share code, notes, and snippets.

@brunodb3
Last active June 23, 2021 10:02
Show Gist options
  • Save brunodb3/924d5ce3c5c147532e6a78b40a4eaeed to your computer and use it in GitHub Desktop.
Save brunodb3/924d5ce3c5c147532e6a78b40a4eaeed to your computer and use it in GitHub Desktop.
Example travis.yml
language: node_js
node_js:
- "12.14"
before_deploy: "npm run build"
jobs:
include:
- stage: Test
script:
- npm run test
- stage: Version
if: tag IS NOT present AND branch = master AND commit_message !~ /^Version /
script:
# Set up SSH key for GitHub
- >-
openssl aes-256-cbc
-K $encrypted_XXXXXXXXXX_key
-iv $encrypted_XXXXXXXXXX_iv
-in github_deploy_key.enc
-out github_deploy_key
-d
- chmod 600 github_deploy_key
- eval $(ssh-agent -s)
- ssh-add github_deploy_key
# Patch for NPM
- npm version patch -m "Version %s"
# Set remote to SSH instead of HTTPS
- git remote set-url origin [email protected]:<USERNAME/<PROJECT>.git
# Push new tag to GitHub, triggering a new build
- git push origin HEAD:master --follow-tags
on:
tags: false
- stage: Release
if: tag IS present AND commit_message =~ /^Version /
script: npm run build
deploy:
provider: npm
email: $NPM_EMAIL
api_token: $NPM_TOKEN
skip_cleanup: true
on:
tags: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment