image: node:18 workflow: rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" - if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS when: never - if: $CI_COMMIT_BRANCH stages: - build - test - deploy_staging - deploy_prod build_assets: cache: - key: files: - yarn.lock paths: - .yarn-cache/ - node_modules/ stage: build before_script: - yarn install --immutable --immutable-cache --check-cache script: - yarn build artifacts: expire_in: 1h paths: - public test_karma: stage: test dependencies: - build_assets before_script: - apt-get update && apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget - yarn install --immutable --immutable-cache --check-cache script: - yarn test version_assets: stage: deploy_prod only: - tags before_script: - yarn install --immutable --immutable-cache --check-cache - git config --global user.email "gitlab_bot@tulip.io" - git config --global user.name "Mr Roboto" script: - git remote set-url origin "git@git.internal.tulip.io:${CI_PROJECT_PATH}.git" - git remote -v - git fetch origin - git checkout ${CI_DEFAULT_BRANCH} - yarn version --new-version="${CI_COMMIT_TAG#v}" - git commit -m "Bumping version to $CI_COMMIT_TAG" - git push origin HEAD:${CI_DEFAULT_BRANCH} dependencies: - build_assets artifacts: expire_in: 1h paths: - public s3_deploy_staging: stage: deploy_staging rules: - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest script: - echo 'Checking built assets are available' - ls -alhS public/build - echo 'Copying distribution files to s3 s3 connection' - aws s3 cp public/build/ s3://timekit-cdn-staging/booking-js/v3/ --recursive dependencies: - build_assets s3_deploy_prod: stage: deploy_prod rules: - if: $CI_COMMIT_TAG image: registry.gitlab.com/gitlab-org/cloud-deploy/aws-base:latest script: - echo 'Checking built assets are available' - ls -alhS public/build - echo 'Copying distribution files to s3 s3 connection' - aws s3 cp --dryrun public/build/ s3://timekit-cdn/booking-js/v3/ --recursive dependencies: - build_assets - version_assets