How do I get the value of the url from the post request and use it on the git repo

229 Views Asked by At

I have an argo sensor that triggers a workflow after receiving an event from event bus.

I want to get the value of the post request and use it as a git url to clone the repository into argo workflow

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: webhook
  namespace: argo-events
spec:
  template:
    serviceAccountName: operate-workflow-sa
  dependencies:
    - name: test-dep
      eventSourceName: webhook
      eventName: example
  triggers:
    - template:
        name: webhook-workflow-trigger
        k8s:
          group: argoproj.io
          version: v1alpha1
          resource: workflows
          operation: create
          source:
            resource:
              apiVersion: argoproj.io/v1alpha1
              kind: Workflow
              metadata:
                name: s3-react-upload
              spec:
                entrypoint: git-clone
                arguments:
                  parameters:
                    - name: url
                      value: hello world
                templates:
                  - name: git-clone
                    inputs:
                      artifacts:
                        - name: argo-source
                          path: /src
                          git:
                            repo: "{{inputs.parameters.url}}"
                    container:
                      image: node:16-alpine3.17
                      command: [sh, -c]
                      args: ["npm install && npm run build"]
                      workingDir: /src
                    outputs:
                      artifacts:
                        - name: message
                          path: /src/build
                          archive:
                            none: {}
                          s3:
                            endpoint: s3.amazonaws.com
                            bucket: ignite-react-app-2023
                            region: eu-west-2
                            key: "."
                            accessKeySecret:
                              name: mysecret
                              key: accessKey
                            secretKeySecret:
                              name: mysecret
                              key: secretKey
          parameters:
            - src:
                dependencyName: test-dep
                dataKey: body.url
              dest: spec.arguments.parameters.0.value

curl

curl -d '{"url":"https://github.com/not-real-name/ci-cd"}' -H "Content-Type: application/json" -X POST http://localhost:12000/deploy

I am getting this error

Failed: invalid spec: templates.git-clone: failed to resolve {{inputs.parameters.url}}

0

There are 0 best solutions below