From 65cb6a010306cc251007abe2951a2080caf73fff Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Thu, 16 Dec 2021 10:08:20 -0700 Subject: [PATCH] Update pipeline --- .gitlab-ci.yml | 103 +++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 54 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 342675d..36fb419 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,99 +1,94 @@ variables: GITLAB_TOKEN: '${CI_JOB_TOKEN}' - NODE_IMAGE_NAME: ${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_SLUG} - -include: - - project: 'ghsc/hazdev/pipeline-build-template' - ref: '1.1.3' - file: 'templates/library.yml' + NODE_IMAGE_NAME: ${CODE_REGISTRY_IMAGE}/${CI_PROJECT_NAME}:${CI_COMMIT_REF_SLUG}--node stages: + - init - node-image - - test + - build - publish -# Do not run for merge requests -workflow: - rules: - - if: $CI_COMMIT_TAG - - if: $CI_COMMIT_BRANCH - -#### -# Template: GitLab runner tags -#### -.dev-tags: - tags: - - development - #### -# Template: Run Node +# Stage: init #### -.node: - image: ${NODE_IMAGE_NAME} - extends: - - .tags::development - before_script: +Init: + artifacts: + paths: + - node_modules + image: ${DEVOPS_REGISTRY}usgs/node:16 + script: - npm ci + stage: init #### # Stage: Node Image #### Build Node Image: - extends: - - .dind - - .tags::build + image: ${DEVOPS_REGISTRY}docker:19.03-git + needs: [] script: - | docker build \ - --build-arg FROM_IMAGE=${DEVOPS_REGISTRY}usgs/node:latest \ - --file "Dockerfile" \ + --build-arg FROM_IMAGE=${DEVOPS_REGISTRY}usgs/node:16 \ + --file ".gitlab/Dockerfile" \ --pull \ --tag ${NODE_IMAGE_NAME} \ . - docker push ${NODE_IMAGE_NAME} + services: + - alias: docker + name: ${DEVOPS_REGISTRY}docker:19.03-dind stage: node-image + tags: + - build + variables: + DOCKER_DRIVER: overlay2 #### -# Stage: test +# Stage: Build #### -Build Angular: +.node: + image: ${DEVOPS_REGISTRY}usgs/node:16 needs: - - Build Node Image - stage: test - extends: .node + - Init + stage: build + tags: + - development + +Build: + extends: + - .node script: - - cd example - - npm i - npm run build -Lint: - needs: - - Build Node Image - stage: test - extends: .node +Lint Project: + extends: + - .node script: - - npm run tslint + - npm run lint #### -# Stage: publish +# Stage: Publish #### Publish npm: - needs: - - Build Node Image - stage: publish image: ${NODE_IMAGE_NAME} - extends: .dev-tags only: - - tags@ghsc/nshmp/disagg-d3 - before_script: - - echo '//code.usgs.gov/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}' >> .npmrc - - npm ci + - tags + script: - git config user.email "${GITLAB_USER_EMAIL}" - git config user.name "${GITLAB_USER_NAME}" - script: + - npm run build + - | + cat <<-EO_CONFIG > .npmrc + @${CI_PROJECT_ROOT_NAMESPACE}:registry=https://${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/ + //${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN} + EO_CONFIG - npx standard-version --release-as ${CI_COMMIT_TAG} --skip.commit --skip.changelog - npm publish --access public + stage: publish + tags: + - development -- GitLab