apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: send-to-channel-slack
  labels:
    app.kubernetes.io/version: "0.1"
  annotations:
    tekton.dev/pipelines.minVersion: "0.12.1"
    tekton.dev/categories: Messaging
    tekton.dev/tags: messaging
    tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le"
spec:
  description: >-
    These tasks post a simple message to a slack channel.

    This task uses chat.postMessage slack REST api to send the message.
    There are multiple ways to send a message to slack.

  params:
  - name: token-secret
    type: string
    description: secret name of the slack app access token (key is token)
  - name: channel
    type: string
    description: channel id or channel name
  - name: message
    type: string
    description: plain text message
  steps:
  - name: post
    image: docker.io/curlimages/curl:7.70.0@sha256:031df77a11e5edded840bc761a845eab6e3c2edee22669fb8ad6d59484b6a1c4 #tag: 7.70.0
    script: |
      #!/bin/sh
      /usr/bin/curl -X POST -H 'Content-type: application/json' -H 'Authorization: Bearer '$TOKEN --data '{"channel":"$(params.channel)", "text":"$(params.message)"}' https://slack.com/api/chat.postMessage
    env:
    - name: TOKEN
      valueFrom:
        secretKeyRef:
          name: $(params.token-secret)
          key: token