{"id":20463208,"url":"https://github.com/devwithkrishna/github-workflow-dispatch-test","last_synced_at":"2026-01-28T00:38:55.052Z","repository":{"id":247985774,"uuid":"827385220","full_name":"devwithkrishna/github-workflow-dispatch-test","owner":"devwithkrishna","description":"Trigger a workflow from another workflow","archived":false,"fork":false,"pushed_at":"2024-07-11T20:28:50.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-01T16:30:39.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devwithkrishna.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-11T14:53:00.000Z","updated_at":"2024-07-11T20:27:22.000Z","dependencies_parsed_at":"2024-07-11T18:43:33.255Z","dependency_job_id":"82d8041c-f982-4f0b-b048-962b0fb52d91","html_url":"https://github.com/devwithkrishna/github-workflow-dispatch-test","commit_stats":null,"previous_names":["devwithkrishna/github-workflow-dispatch-test"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/devwithkrishna/github-workflow-dispatch-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fgithub-workflow-dispatch-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fgithub-workflow-dispatch-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fgithub-workflow-dispatch-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fgithub-workflow-dispatch-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devwithkrishna","download_url":"https://codeload.github.com/devwithkrishna/github-workflow-dispatch-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devwithkrishna%2Fgithub-workflow-dispatch-test/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28829518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T23:29:49.665Z","status":"ssl_error","status_checked_at":"2026-01-27T23:25:58.379Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T13:09:54.594Z","updated_at":"2026-01-28T00:38:55.030Z","avatar_url":"https://github.com/devwithkrishna.png","language":null,"readme":"# github-workflow-dispatch-test\nTrigger a workflow from another workflow\n\n# Why this repo ?\n\n* This was created in order to test differnt methos to trigger a workflow other than push event, or schedule etc.\n\n* This repo contains 2 different methods we can trigger a workflow from another workflow\n\n\n# Details\n\n## workflow_dispatch method\n\n* We will utilize GitHub REST API end point for triggering a workflow by providing necessary credential.\n\n[create-a-workflow-dispatch-event](https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event)\n\ni am passing ***GitHub app installation access*** token to trigger the workflow. Similarly we can pass either *Github app user access token* or *fine grained personal access tokens*\n\n```\n- name: Token generator\n  uses: githubofkrishnadhas/github-access-using-githubapp@v1\n  with:\n    github_app_id: ${{ secrets.WDC_APP_ID }}\n    github_app_private_key : ${{ secrets.WDC_PVT_KEY }}\n    github_account_type : organization\n\n```\n\n* use the above action to generate a GitHub app Installation token and later pass it to the GItHub rest API call to do the authentication. The token will be available as **GH_APP_TOKEN** env variable in workflow.\n\n* `WDC_APP_ID` , `WDC_PVT_KEY` are respectively the app id and private key of github app which is stored as secrets in github .\n\n```\n    - name: Trigger another workflow via API\n      env:\n        OWNER_REPO: ${{ github.repository }}\n        WORKFLOW_ID: workflow_dispatch_child.yaml  # or the workflow ID if you prefer\n        REF: main  # or the branch you want to use\n      run: |\n        curl -L \\\n          -X POST \\\n          -H \"Accept: application/vnd.github+json\" \\\n          -H \"Authorization: Bearer $GH_APP_TOKEN\" \\\n          https://api.github.com/repos/${{ env.OWNER_REPO }}/actions/workflows/$WORKFLOW_ID/dispatches \\\n          -d '{\"ref\":\"main\",\"inputs\":{\"name\":\"Kunai the Octocat\",\"home\":\"Tokiyo, Japan\"}}'\n        \n```\n\n* OWNER_REPO --\u003e this will be the complete repo name in format of `github orgname/repository name`\n\n* WORKFLOW_ID --\u003e This can be either the workflow file name or ID of the workflow \n\n* Inside inputs you can pass necessary params to next workflow.\n\n* This will trigger a workflow named `workflow_dispatch_child.yaml` post completing the API call and pass name and home as inputs for next workflow.\n\n\n## worlfow_run method\n\n* `workflow_run` method provides more importance to workflow name. here it is `Build`\n\n```\nname: Build\non:\n  workflow_dispatch: # this is optional\n  workflow_run:\n  # This workflow will only run in main branch when Trigger a workflow using workflow_run is comlpeted\n    workflows: [\"Trigger a workflow using workflow_run\"] \n    types: [completed]\n      # branches-ignore:\n      #   - \"feature/*\"\n    branches:\n      - \"main\"\n\n```\n\n* The name inside workflows: [\"x\"] , this x will be the workflow name and the workflow which will be triggered first then Build.\n\n* types : There are 3 values  [workflow_run](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run)\n\n    * completed\n    * in-progress\n    * requested\n\n* when using `requested`, as soon as the parent workflow is triggered child is also. The requested activity type does not \n  occur when a workflow is re-run.\n\n* when using `in-progress`, as the parent workflow is executing child workflow is triggered\n\n* when using `completed`, the child workflow will wait till parent is completed.\n\n* `branches`: this we can provide a list of branch names or with regex [eg: feature/* for all feature branches starting with feature/ in name] to run on these branches\n\n* `branches-ignore`: This we can also provide a list of names or also with regex . the workflow wont run on branches\n  specifiedd under branches-ignore\n\n* **`branches` and `branches`-ignore can not be used simultaneously.**\n\n\njust for identification added print statements on child workflow ro specify from which workflo_run, the job is triggered.\n\n![alt text](\u003cPrint triggering workflow and build number.jpeg\u003e)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fgithub-workflow-dispatch-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevwithkrishna%2Fgithub-workflow-dispatch-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevwithkrishna%2Fgithub-workflow-dispatch-test/lists"}