|
| 1 | +version: 2.1 |
| 2 | +orbs: |
| 3 | + slack: circleci/slack@3.4.2 |
| 4 | +commands: |
| 5 | + npm_install_from_cache: |
| 6 | + description: "npm install and save cache" |
| 7 | + steps: |
| 8 | + - restore_cache: |
| 9 | + key: v1-deps-{{ checksum "package-lock.json" }} |
| 10 | + - run: |
| 11 | + name: Install npm dependencies |
| 12 | + command: npm install |
| 13 | + - save_cache: |
| 14 | + key: v1-deps-{{ checksum "package-lock.json" }} |
| 15 | + paths: |
| 16 | + - node_modules |
| 17 | + build: |
| 18 | + description: "Build Docusaurus project" |
| 19 | + steps: |
| 20 | + - run: |
| 21 | + name: Building Docusaurus project |
| 22 | + command: npm run build |
| 23 | + |
| 24 | + versioning: |
| 25 | + description: "Versioning the image" |
| 26 | + parameters: |
| 27 | + version_name: |
| 28 | + type: string |
| 29 | + default: "staging" |
| 30 | + steps: |
| 31 | + - run: |
| 32 | + name: Tag build |
| 33 | + command: echo "<< parameters.version_name >> $(date -u +'%Y-%m-%dT%H:%M:%SZ')" > build/version |
| 34 | + |
| 35 | + notify_slack: |
| 36 | + description: "Notify slack" |
| 37 | + steps: |
| 38 | + - slack/status: |
| 39 | + include_project_field: false |
| 40 | + failure_message: "Release failed for api.deriv.com with version *$(cat build/version)*" |
| 41 | + success_message: "Release succeeded for api.deriv.com with version *$(cat build/version)*" |
| 42 | + webhook: ${SLACK_WEBHOOK} |
| 43 | + publish_to_pages_staging: |
| 44 | + description: "Publish to cloudflare pages" |
| 45 | + steps: |
| 46 | + - run: |
| 47 | + name: "Publish to cloudflare pages (staging)" |
| 48 | + command: | |
| 49 | + npm i wrangler@2.0.19 |
| 50 | + cd build |
| 51 | + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=staging |
| 52 | + echo "New staging website - https://staging-api.deriv.com/" |
| 53 | +
|
| 54 | + publish_to_pages_production: |
| 55 | + description: "Publish to cloudflare pages" |
| 56 | + steps: |
| 57 | + - run: |
| 58 | + name: "Publish to cloudflare pages (production)" |
| 59 | + command: | |
| 60 | + npm i wrangler@2.0.19 |
| 61 | + cd build |
| 62 | + npx wrangler pages publish . --project-name=deriv-developers-portal-pages --branch=main |
| 63 | + echo "New website - https://api.deriv.com" |
| 64 | +
|
| 65 | +jobs: |
| 66 | + build: |
| 67 | + docker: |
| 68 | + - image: cimg/node:18.16.0 |
| 69 | + steps: |
| 70 | + - checkout |
| 71 | + - npm_install_from_cache |
| 72 | + - build |
| 73 | + |
| 74 | + release_staging: |
| 75 | + docker: |
| 76 | + - image: cimg/node:18.16.0 |
| 77 | + steps: |
| 78 | + - checkout |
| 79 | + - npm_install_from_cache |
| 80 | + - build |
| 81 | + - versioning |
| 82 | + - publish_to_pages_staging |
| 83 | + - notify_slack |
| 84 | + environment: |
| 85 | + NODE_ENV: staging |
| 86 | + |
| 87 | + release_production: |
| 88 | + docker: |
| 89 | + - image: cimg/node:18.16.0 |
| 90 | + steps: |
| 91 | + - checkout |
| 92 | + - npm_install_from_cache |
| 93 | + - build |
| 94 | + - versioning: |
| 95 | + version_name: production |
| 96 | + - publish_to_pages_production |
| 97 | + - notify_slack |
| 98 | + environment: |
| 99 | + NODE_ENV: production |
| 100 | + |
| 101 | +workflows: |
| 102 | + release_staging: |
| 103 | + jobs: |
| 104 | + - release_staging: |
| 105 | + context: binary-frontend-artifact-upload |
| 106 | + filters: |
| 107 | + branches: |
| 108 | + only: /^master$/ |
| 109 | + release_production: |
| 110 | + jobs: |
| 111 | + - release_production: |
| 112 | + context: binary-frontend-artifact-upload |
| 113 | + filters: |
| 114 | + branches: |
| 115 | + ignore: /.*/ |
| 116 | + tags: |
| 117 | + only: /^production.*/ |
0 commit comments