I have a Github repository (repo A) with a workflow running inside that repo (working with Terraform file and applying them on AWS). I am trying to trigger that workflow from a different Github repository (repo B), so I created a workflow in repo B, made a checkout to repo A and then tried to trigger the workflow with "gh" CLI.
jobs:
traffic-split:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout to repo A
uses: actions/checkout@master
with:
repository: <My_Organization>/<My_Called_Repo>
token: ${{ secrets.GH_TOKEN }}
- name: Run Workflow
run: |
curl -X POST -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/<My_Organization>/<My_Called_Repo>/.github/workflows/<My_Called_Worflow>/dispatches"
However, it fails with 404 NOT FOUND.
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/actions#create-a-workflow-dispatch-event"
}
When running other GH CLI commands like "gh workflow list", etc. it works, but triggering a workflow fails. What am I missing when triggering the workflow?
Thank you!
2
Answers
Try using GitHub action:
workflow-dispatch
Try using GitHub API Docs:
GitHub API