# Originally copied from Jump Software's navigation app (closed source) # See import map at https://app.jumpsoftware.com/import-map.json # This assumes the name of the javascript output file is the same as the name of the gitlab repo. image: node:10-slim stages: - setup - build - deploy-stage - deploy-prod install: stage: setup script: npm ci artifacts: paths: - node_modules test: stage: build script: npm test dependencies: - install build: stage: build script: npm run build dependencies: - install artifacts: paths: - build .deploy: image: registry.gitlab.com/mycompany/aws-tools:latest before_script: - echo "Commit sha is $CI_COMMIT_SHORT_SHA. This will be the directory name under $CI_PROJECT_NAME in S3." script: - aws s3 sync build/ s3://$DEPLOYER_BUCKET/$CI_PROJECT_NAME/$CI_COMMIT_SHORT_SHA --cache-control max-age=31536000 - echo "Updating import map" - curl -u $DEPLOYER_USERNAME:$DEPLOYER_PASSWORD -d '{ "service":"@mycompany/'"$CI_PROJECT_NAME"'","url":"https://'"$CF_PUBLIC_URL"'/'"$CI_PROJECT_NAME"'/'"$CI_COMMIT_SHORT_SHA"'/'"$CI_PROJECT_NAME"'.js" }' -X PATCH https://$DEPLOYER_HOST/services\?env=$CI_ENVIRONMENT_NAME -H "Accept:application/json" -H "Content-Type:application/json" dependencies: - build only: - master deploy-stage: extends: .deploy stage: deploy-stage environment: name: stage variables: DEPLOYER_BUCKET: "$STAGING_SINGLESPA_BUCKET" DEPLOYER_HOST: "$STAGING_DEPLOYER_HOST" CF_PUBLIC_URL: app.staging.somecompany.com deploy-prod: extends: .deploy stage: deploy-prod environment: name: prod variables: DEPLOYER_BUCKET: "$PRODUCTION_SINGLESPA_BUCKET" DEPLOYER_HOST: "$PRODUCTION_DEPLOYER_HOST" CF_PUBLIC_URL: app.somecompany.com when: manual