cache:
    pipeline: [~/.npm]

shared:
    image: node:12

jobs:
    main:
        steps:
            - install: yarn install --frozen-lockfile
            - lint: yarn lint
            - test: yarn test-ci
        requires:
            - ~pr
            - ~commit

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

    docs:
        requires: publish
        steps:
            - setup-ci: git clone https://github.com/screwdriver-cd/toolbox.git /tmp/ci
            - install: yarn install --frozen-lockfile
            - docs: |
                  . /tmp/ci/git-ssh.sh
                  git remote set-url origin `git remote get-url --push origin`
                  yarn deploy-storybook
        secrets:
            - GIT_KEY_BASE64
