Skip to content

Instantly share code, notes, and snippets.

@lachlanagnew
Last active February 21, 2019 23:11
Show Gist options
  • Select an option

  • Save lachlanagnew/71ddb4d434d11d27a52de6da64bf471d to your computer and use it in GitHub Desktop.

Select an option

Save lachlanagnew/71ddb4d434d11d27a52de6da64bf471d to your computer and use it in GitHub Desktop.
image: node:9.11.1
stages:
- build
- test
- deploy
before_script:
- apt-get update --quiet --yes
build-job:
# Script to run for building the application
script:
- npm install
- npm run-script build
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/
- dist/
- build/
# Current stage in the pipeline
stage: build
# Applies only to branches
only:
- branches
# Excludes commits for tags and triggers
except:
- triggers
test-job:
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/
- dist/
- build/
script:
- npm test
stage: test
only:
- branches
except:
- triggers
deploy-job-staging:
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/
- dist/
- build/
# Script to run for deploying application to AWS
script:
- apt-get --quiet install --yes zip python-dev python-pip
- pip install awscli
- zip build ./ -r # Builds the zip file to be sent to s3
- aws s3 cp ./build.zip $AWS_S3_LOCATION # Uploads the zipfile to S3 and expects the AWS Code Pipeline/Code Deploy to pick up
# requires previous CI stages to succeed in order to execute
when: on_success
stage: deploy #assigns the stage as deploy
environment: production # Assign the Gitlab Environment for tracking purposes
only:
- staging
# Excludes commits for tags and triggers
except:
- triggers
deploy-job-production:
cache:
key: $CI_COMMIT_REF_SLUG
paths:
- node_modules/
- dist/
- build/
# Script to run for deploying application to AWS
script:
- apt-get --quiet install --yes zip python-dev python-pip
- pip install awscli
- zip build ./ -r # Builds the zip file to be sent to s3
- aws s3 cp ./build.zip $AWS_S3_LOCATION_PROD # Uploads the zipfile to S3 and expects the AWS Code Pipeline/Code Deploy to pick up
# requires previous CI stages to succeed in order to execute
when: on_success
stage: deploy #assigns the stage as deploy
environment: production # Assign the Gitlab Environment for tracking purposes
only:
- master
# Excludes commits for tags and triggers
except:
- triggers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment