cache:
  pipeline: [~/.yarn]

shared:
  image: node:18

jobs:
  main:
    annotations:
      screwdriver.cd/ram: TURBO
      screwdriver.cd/cpu: TURBO
    steps:
      - install-chrome: ./build-scripts/setup-chrome.sh
      - yarn-cache: yarn config set cache-folder ~/.yarn
      - install: yarn install --frozen-lockfile
      - test: yarn test
    requires:
      - ~pr
      - ~commit
    environment:
      JOBS: 2

  publish:
    requires: main
    steps:
      - yarn-cache: yarn config set cache-folder ~/.yarn
      - install: yarn install --frozen-lockfile
      - setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git /tmp/ci
      - publish: |
          . /tmp/ci/git-ssh.sh
          yarn semantic-release
    secrets:
      - NPM_TOKEN
      - GH_TOKEN
      - GIT_KEY_BASE64

  gh-pages:
    requires: publish
    steps:
      - setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git /tmp/ci
      - yarn-cache: yarn config set cache-folder ~/.yarn
      - install: yarn install --frozen-lockfile
      - build-pages: |
          npx ember github-pages:commit --message "Deploy gh-pages from $SD_BUILD_SHA"
      - deploy: |
          . /tmp/ci/git-ssh.sh
          git push origin gh-pages:gh-pages
    secrets:
      - GIT_KEY_BASE64
    environment:
      JOBS: 2
