diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index b031078..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -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: /.*/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..46930e5 --- /dev/null +++ b/.gitlab-ci.yml @@ -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 diff --git a/README.md b/README.md index c24fa5d..c415932 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/webpack.common.js b/webpack.common.js index e663909..34b642b 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -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'));