---
kind: pipeline
type: docker
name: default

steps:
  - name: dependencies
    image: deblan/devenv
    commands:
      - npm install

  - name: build
    image: deblan/devenv
    commands:
      - make npm-build
    when:
      branch:
        exclude:
          - master
        include:
          - develop
          - feature/*
      event:
        - push
        - pull_request

  - name: release
    image: deblan/devenv
    volumes:
      - name: artifacts
        path: /artifacts
    environment:
      APP_CERTIFICATE:
        from_secret: app_certificate
    commands:
      - mkdir -p "$HOME/.nextcloud/certificates"
      - echo "$APP_CERTIFICATE" > "$HOME/.nextcloud/certificates/side_menu.key"
      - export VERSION=$(grep "<version>" appinfo/info.xml | grep -o "[0-9]*\.[0-9]*\.[0-9]*" --color=never)
      - export RELEASE_DIRECTORY="/artifacts/deblan/side_menu"
      - make release
    when:
      branch:
        exclude:
          - develop
          - feature/*
        include:
          - master
      event:
        - push

volumes:
  - name: artifacts
    host:
      path: /var/www/html/artifacts
