github.com/kubevela/workflow@v0.6.0/examples/request-and-notify.md (about)

     1  # Use Workflow for request and notify
     2  
     3  Apply the following workflow for request a specified URL first and then use the response as a message to your slack channel.
     4  
     5  ```yaml
     6  apiVersion: core.oam.dev/v1alpha1
     7  kind: WorkflowRun
     8  metadata:
     9    name: request-http
    10    namespace: default
    11  spec:
    12    workflowSpec:
    13      steps:
    14      - name: request
    15        type: request
    16        properties:
    17          url: https://api.github.com/repos/kubevela/workflow
    18        outputs:
    19          - name: stars
    20            valueFrom: |
    21              import "strconv"
    22              "Current star count: " + strconv.FormatInt(response["stargazers_count"], 10)
    23      - name: notification
    24        type: notification
    25        inputs:
    26          - from: stars
    27            parameterKey: slack.message.text
    28        properties:
    29          slack:
    30            url:
    31              value: <your slack url>
    32      - name: failed-notification
    33        type: notification
    34        if: status.request.failed
    35        properties:
    36          slack:
    37            url:
    38              value: <your slack url>
    39            message:
    40              text: "Failed to request github"
    41              
    42  ```
    43  
    44  Above workflow will send a request to the GitHub API and get the star count of the workflow repository as an output, then use the output as a message to send a notification to your Slack channel.
    45  
    46  Apply the WorkflowRun, you can get a message from Slack like:
    47  
    48  ![slack-success](./static/slack-success.png)
    49  
    50  If you change the `url` to an invalid one, you will get a failed notification:
    51  
    52  ![slack-failed](./static/slack-fail.png)