kind: pipeline
name: testing

trigger:
  branch:
    exclude:
      - master
  event:
    - push

steps:
  - name: build
    image: kolaente/yarn
    pull: true
    group: build-static
    commands:
      - yarn --frozen-lockfile
      - yarn run lint
      - yarn run build

---
kind: pipeline
name: release-latest

trigger:
  branch:
    - master
  event:
    - push

steps:
  - name: build
    image: kolaente/yarn
    pull: true
    group: build-static
    commands:
      - yarn --frozen-lockfile
      - yarn run lint
      - "echo '{\"VIKUNJA_API_BASE_URL\": \"/api/v1/\"}' > /drone/src/public/config.json" # Override config
      - yarn run build

  - name: static
    image: kolaente/zip
    pull: true
    commands:
      - cd dist
      - zip -r ../vikunja-frontend-master.zip *
      - cd ..
    depends_on: [ build ]

  - name: release
    image: plugins/s3:1
    pull: true
    settings:
      bucket: vikunja-frontend
      access_key:
        from_secret: aws_access_key_id
      secret_key:
        from_secret: aws_secret_access_key
      endpoint: https://storage.kolaente.de
      path_style: true
      source: vikunja-frontend-master.zip
    depends_on: [ static ]

  # Build the docker image and push it to docker hub
  - name: docker
    image: plugins/docker
    pull: true
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: vikunja/frontend
      auto_tag: true
    depends_on: [ static ]

---
kind: pipeline
name: release-version

trigger:
  event:
    - tag

steps:
  - name: build
    image: kolaente/yarn
    pull: true
    group: build-static
    commands:
      - yarn --frozen-lockfile
      - yarn run lint
      - "echo '{\"VIKUNJA_API_BASE_URL\": \"/api/v1/\"}' > /drone/src/public/config.json" # Override config
      - yarn run build

  - name: static
    image: kolaente/zip
    pull: true
    commands:
      - cd dist
      - zip -r ../vikunja-frontend-${DRONE_TAG##v}.zip *
      - cd ..
    depends_on: [ build ]

  - name: release
    image: plugins/s3:1
    pull: true
    settings:
      bucket: vikunja-frontend
      access_key:
        from_secret: aws_access_key_id
      secret_key:
        from_secret: aws_secret_access_key
      endpoint: https://storage.kolaente.de
      path_style: true
      source: vikunja-frontend-${DRONE_TAG##v}.zip
    depends_on: [ static ]

  # Build the docker image and push it to docker hub
  - name: docker
    image: plugins/docker
    pull: true
    settings:
      username:
        from_secret: docker_username
      password:
        from_secret: docker_password
      repo: vikunja/frontend
      auto_tag: true
    depends_on: [ static ]