convictional / trigger-workflow-and-wait

Trigger a workflow in another (or same) repository and wait for the job to finish.
MIT License
311 stars 151 forks source link

Is it possible to add example with valid payload which trigger and wait for workflow in other repository? #82

Open danieltalmor369 opened 1 year ago

danieltalmor369 commented 1 year ago

I provided a json string

- name: Execute deployment and wait for finish
        uses: convictional/trigger-workflow-and-wait@v1.6.1
        with:
          owner: ME
          repo: my-workflows
          github_token: ${{ secrets. GITHUB_TOKEN }}
          github_user: ${{ github.event.client_payload.actor }}
          workflow_file_name: deployment.yml
          ref: ${{ github.event.inputs.ref }}
          client_payload: '{"ref": "master", "inputs": {"repository": "${{ github.event.inputs.repository }}", "ref": "${{ github.event.inputs.ref }}", "environment": "${{ github.event.inputs.environment }}", "service_to_deploy": "${{ github.event.inputs.service_to_deploy }}"}}'

But I get an error on the payload:

curl: (22) The requested URL returned error: 422 is not a string
loki1978 commented 1 year ago

        - uses: convictional/trigger-workflow-and-wait@v1.6.5
        with:
            owner: BAC
            repo: xyz
            github_token: ${{ secrets.TOKEN }}
            github_user: user10
            workflow_file_name: metrics.yml
            ref: master
            wait_interval: 2
            client_payload: '{"repository": "ABC", "application": "12", "deploy_tag": "ABC", "previous_deploy_tag": "ABC", "deploy_status": "true", "build_duration": "12.5"}'
            trigger_workflow: true
            wait_workflow: true
danieltalmor369 commented 1 year ago

Thanks @loki1978 I still getting the same error

curl: (22) The requested URL returned error: 422
api failed:
path: workflows/qa_deployment.yml/dispatches
response: {
  "message": "Invalid request.\n\nFor 'additionalProperties', {\"repository\"=>\"klinse\", \"ref\"=>\"feature/johnnyT/Aicore-20/combine-deploy-workflows\", \"environment\"=>\"qa-1\", \"env_start\"=>\"disabled\", \"service_to_deploy\"=>\"data_ingestor\"} is not a string.",
  "documentation_url": "https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event"
}

I try to wait for external workflow (which locate in other repository. Do I need to set something on the triggered workflow?

FelixZilber commented 1 year ago

Same for me.

using client_payload: '{"data":"I am a custom client_payload"}' results in Triggering workflow: workflows/testing-workflow.yml/dispatches {"ref":"master","inputs":{"data":"I am a custom client_payload"}} curl: (22) The requested URL returned error: 422 api failed: path: workflows/testing-workflow.yml/dispatches response: { "message": "Unexpected inputs provided: [\"data\"]", "documentation_url": "https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event" }

loki1978 commented 1 year ago

Thanks @loki1978 I still getting the same error

curl: (22) The requested URL returned error: 422
api failed:
path: workflows/qa_deployment.yml/dispatches
response: {
  "message": "Invalid request.\n\nFor 'additionalProperties', {\"repository\"=>\"klinse\", \"ref\"=>\"feature/johnnyT/Aicore-20/combine-deploy-workflows\", \"environment\"=>\"qa-1\", \"env_start\"=>\"disabled\", \"service_to_deploy\"=>\"data_ingestor\"} is not a string.",
  "documentation_url": "https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event"
}

I try to wait for external workflow (which locate in other repository. Do I need to set something on the triggered workflow?

Triggered workflow need workflow dispatch and inputs ( optional )


  workflow_dispatch:
    inputs:
KeshariPiyush24 commented 1 year ago

Thanks @loki1978 I still getting the same error

curl: (22) The requested URL returned error: 422
api failed:
path: workflows/qa_deployment.yml/dispatches
response: {
  "message": "Invalid request.\n\nFor 'additionalProperties', {\"repository\"=>\"klinse\", \"ref\"=>\"feature/johnnyT/Aicore-20/combine-deploy-workflows\", \"environment\"=>\"qa-1\", \"env_start\"=>\"disabled\", \"service_to_deploy\"=>\"data_ingestor\"} is not a string.",
  "documentation_url": "https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event"
}

I try to wait for external workflow (which locate in other repository. Do I need to set something on the triggered workflow?

Triggered workflow need workflow dispatch and inputs ( optional )

  workflow_dispatch:
    inputs:

Yes the workflow which you are triggering should have:

on:
  workflow_dispatch: