Last active
August 23, 2020 13:44
-
-
Save ali-kamalizade/9a8a445f0e7daa05f27c7001b723c703 to your computer and use it in GitHub Desktop.
A sample GitLab CI configuration file for building, testing and deploying a JavaScript based project to Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file is a template, and might need editing before it works on your project. | |
# Official framework image. Look for the different tagged releases at: | |
# https://hub.docker.com/r/library/node/tags/ | |
image: node:12.10.0 | |
# This folder is cached between builds | |
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache | |
cache: | |
paths: | |
- node_modules/ | |
stages: | |
- build | |
- deploy | |
build and test: | |
stage: build | |
script: | |
- npm ci | |
- npm run build | |
- npm run test | |
deployment: | |
stage: deploy | |
only: | |
- master | |
script: | |
- echo $GITLAB_USER_NAME has started a release | |
- echo "Last commit $CI_COMMIT_MESSAGE" | |
- git remote add heroku https://heroku:$MY_HEROKU_API_KEY@git.heroku.com/<MY_APP>.git | |
- git push -q heroku HEAD:master | |
# Optional: check health check. See my post: https://medium.com/better-programming/how-to-add-a-health-check-to-your-node-js-app-5154d13b969e | |
- echo Checking health check after deployment to verify server is running | |
- curl 'https://<my_app>.herokuapp.com/healthcheck' --compressed --fail --head --retry 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment