---
kind: pipeline
type: docker
name: node16

steps:
- name: install-deps
  image: node:16
  commands:
  - npm install

- name: lint
  image: node:16
  depends_on:
  - install-deps
  commands:
  - npm run lint

- name: build
  image: node:16
  depends_on:
  - install-deps
  commands:
  - npm run build

- name: export
  image: node:16
  depends_on:
  - build
  commands:
  - npm run export

- name: deploy (staging)
  image: node:16
  depends_on:
  - export
  environment:
    TOKEN:
      from_secret: STAGING_TOKEN
  commands:
  - 'curl -XPOST -H "Authorization: $TOKEN" "https://csclub.uwaterloo.ca/~a3thakra/update-csc/"'
  when:
    branch:
    - main

trigger:
  event:
    exclude:
    - pull_request #avoid double build on PRs