Adding GitLab CI config

This commit is contained in:
Jeff Avallone 2018-06-05 07:09:06 -04:00
parent 99b28eb5f2
commit a0468fd06f
4 changed files with 58 additions and 71 deletions

View File

@ -1,66 +0,0 @@
version: 2
jobs:
build_deploy:
docker:
- image: circleci/node:latest
working_directory: ~/repo
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: Run tests
command: yarn test
- store_artifacts:
path: reports
- store_test_results:
path: reports/test-results
- run:
name: Build site
command: yarn build
- store_artifacts:
path: build
- run:
name: Deploy to S3
command: yarn deploy
workflows:
version: 2
preview:
jobs:
- build_deploy:
context: regexper-preview
filters:
tags:
ignore: /.*/
branches:
only: /.*/
prod:
jobs:
- build_deploy:
context: regexper-prod
filters:
tags:
only: /.*/
branches:
ignore: /.*/

54
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,54 @@
cache:
paths:
- node_modules
before_script:
- yarn install
stages:
- test
- build
- deploy
test:
stage: test
coverage: '/^Statements\s*:\s*([^%]+)/'
artifacts:
paths:
- reports/
script:
yarn test
build:
stage: build
artifacts:
paths:
- build/
script:
- yarn build
deploy_preview:
stage: deploy
environment:
name: preview
url: https://preview.regexper.com
variables:
BANNER: preview
CLOUD_FRONT_ID: $PREVIEW_CLOUDFRONT_ID
DEPLOY_BUCKET: $PREVIEW_DEPLOY_BUCKET
DEPLOY_ENV: preview
GA_PROPERTY: $PREVIEW_GA_PROPERTY
script:
- yarn deploy
only:
- react # TODO: Change to master once merged
deploy_production:
stage: deploy
environment:
name: production
url: https://regexper.com
script:
- yarn deploy
only:
- tags

View File

@ -50,12 +50,12 @@ Several environment variables are used to configure the application at build-tim
* `NODE_ENV` - Effects build-time optimizations. Set to `"production"` for builds and unit tests in package.json. Setting to anything else will show a banner in the application's header.
* `GA_PROPERTY` - Google Analytics property ID.
* `SENTRY_KEY` - Sentry.io DSN key for error reporting.
* `CIRCLE_BRANCH`, `CIRCLE_BUILD_NUM`, and `CIRCLE_SHA1` - CircleCI values used to generate build ID. Displayed in application footer and used in Sentry.io error reports.
* `CI_COMMIT_REF_SLUG`, `CI_COMMIT_SHA` - GitLab CI values used to generate build ID. Displayed in application footer and used in Sentry.io error reports.
* `CLOUD_FRONT_ID` - AWS CloudFront distribution ID to invalidating when running `yarn deploy`
* `DEPLOY_BUCKET` - AWS S3 bucket to deploy application to when running `yarn deploy`.
* `DEPLOY_ENV` - Environment the application will be deployed to. Used to report environment in Sentry.io error reports. Typically set to either "preview" or "production".
* `BANNER` - Text to display in header banner. Generally generated from `NODE_ENV`
* `BUILD_ID` - Application build ID. Generated from `CIRCLE_BRANCH`, `CIRCLE_BUILD_NUM`, and `CIRCLE_SHA1` if not set.
* `BUILD_ID` - Application build ID. Generated from `CI_COMMIT_REF_SLUG` and `CI_COMMIT_SHA` if not set.
## License

View File

@ -8,9 +8,8 @@ const HtmlPlugin = require('html-webpack-plugin');
const pkg = require('./package.json');
const buildId = [
process.env.CIRCLE_BRANCH || 'prerelease',
process.env.CIRCLE_BUILD_NUM || '##',
(process.env.CIRCLE_SHA1 || 'gitsha').slice(0, 7)
process.env.CI_COMMIT_REF_SLUG || 'prerelease',
(process.env.CI_COMMIT_SHA || 'gitsha').slice(0, 7)
].join('-');
const pages = fs.readdirSync(path.resolve(__dirname, 'src/pages'));