##########################################################
resource_types:
- name: s3-multi
  type: docker-image
  source:
    repository: kdvolder/s3-resource-simple
- name: slack-notification
  type: docker-image
  source:
    repository: cfcommunity/slack-notification-resource
    tag: latest
#########################################################
resources:
- name: docker-git
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: {{branch}}
    username: kdvolder
    private_key: {{rsa_id}}
    paths:
    - concourse/docker
- name: sts4
  type: git
  source:
    uri: git@github.com:spring-projects/sts4.git
    branch: {{branch}}
    private_key: {{rsa_id}}
- name: s3-boot-properties-vsix
  type: s3
  source:
    bucket: {{s3_bucket}}
    access_key_id: {{s3_accesskey}}
    secret_access_key: {{s3_secretkey}}
    region_name: {{s3_region}}
    regexp: sts4/vscode-extensions/vscode-boot-properties-(.*).vsix
- name: s3-manifest-yaml-vsix
  type: s3
  source:
    bucket: {{s3_bucket}}
    access_key_id: {{s3_accesskey}}
    secret_access_key: {{s3_secretkey}}
    region_name: {{s3_region}}
    regexp: sts4/vscode-extensions/vscode-manifest-yaml-(.*).vsix
- name: website
  type: s3-multi
  source:
    bucket: {{s3_prod_bucket}}
    access_key_id: {{s3_prod_accesskey}}
    secret_access_key: {{s3_prod_secretkey}}
    region_name: {{s3_region}}
    path: snapshot/STS4/vscode-extensions
    options:
    - "--acl public-read"
- name: slack-notification
  type: slack-notification
  source:
    url: https://hooks.slack.com/services/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
- name: docker-image
  type: docker-image
  source:
    username: {{docker_hub_username}}
    password: {{docker_hub_password}}
    repository: kdvolder/sts4-build-env
########################################################################################
jobs:
- name: build-docker-image
  serial: true
  plan:
  - get: docker-git
    trigger: true
  - put: docker-image
    params:
      build: docker-git/concourse/docker
    get_params: 
      skip_download: true
- name: build-vsix
  plan:
  - get: sts4
    trigger: true
  - task: build-vscode-extensions
    file: sts4/concourse/tasks/build-vscode-extensions.yml
    on_success:
      aggregate:
      - put: s3-manifest-yaml-vsix
        params: 
          file: vsix-files/vscode-manifest-yaml-*.vsix
          acl: public-read
      - put: s3-boot-properties-vsix
        params: 
          file: vsix-files/vscode-boot-properties-*.vsix
          acl: public-read
    on_failure:
      put: slack-notification
      params:
        channel: "@kdvolder"
        text: | 
           Concourse ${BUILD_PIPELINE_NAME}/${BUILD_JOB_NAME}/${BUILD_NAME} has failed!
- name: build-website
  plan:
  - aggregate:
    - get: sts4
    - get: s3-manifest-yaml-vsix
      passed:
      - build-vsix
      trigger: true
    - get: s3-boot-properties-vsix
      passed:
      - build-vsix
      trigger: true
  - task: build-website
    file: sts4/concourse/tasks/build-website.yml
  - put: website
    params:
      path: website
