Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.63 KiB
Newer Older
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
variables:
  GITLAB_TOKEN: '${CI_JOB_TOKEN}'
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  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'
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
stages:
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  - node-image
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  - test
  - publish

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
# Do not run for merge requests
workflow:
  rules:
    - if: $CI_COMMIT_TAG
    - if: $CI_COMMIT_BRANCH

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
####
# Template: GitLab runner tags
####
.dev-tags:
  tags:
    - development

####
# Template: Run Node
####
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
.node:
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  image: ${NODE_IMAGE_NAME}
  extends:
    - .tags::development
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  before_script:
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

####
# Stage: Node Image
####

Build Node Image:
  extends:
    - .dind
    - .tags::build
  script:
    - |
      docker build \
        --build-arg FROM_IMAGE=${DEVOPS_REGISTRY}usgs/node:latest \
        --file "Dockerfile" \
        --pull \
        --tag ${NODE_IMAGE_NAME} \
        .
    - docker push ${NODE_IMAGE_NAME}
  stage: node-image
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed

####
# Stage: test
####

Build Angular:
  stage: test
  extends: .node
  script:
    - cd example
    - npm i
    - npm run build

Lint:
  stage: test
  extends: .node
  script:
    - npm run tslint

####
# Stage: publish
####

Publish npm:
  stage: publish
  image: ${DEVOPS_REGISTRY}usgs/node:12
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  extends: .dev-tags
  only:
    - tags@ghsc/nshmp/disagg-d3
  before_script:
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    - echo '//code.usgs.gov/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}' >> .npmrc
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    - npm ci
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    - git config user.email "${GITLAB_USER_EMAIL}"
    - git config user.name "${GITLAB_USER_NAME}"
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  script:
    - npx standard-version --release-as ${CI_COMMIT_TAG} --skip.commit --skip.changelog
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    - npm publish --access public