Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch GH Actions trigger from repository_dispatch to workflow_dispatch to enable running branches #977

Closed
janpio opened this issue Jul 31, 2020 · 4 comments
Assignees
Labels
kind/improvement An improvement to existing feature and code. tech/engines/other Issue in the engines repo that does not fit one of the other labels. tech/engines Issue for tech Engines. topic: ci

Comments

@janpio
Copy link
Member

janpio commented Jul 31, 2020

This is the newer Event for GH: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_dispatch
That would then just get the current branch or commit name as ref param to trigger the "Build Windows" workflow with the workflow configuration from the branch.
You also need to add that event to the on: in the yaml, but that should already be it.

A bit effort is that it requires the workflow_id as a param on the API: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event
Not sure if that is really dynamic, but here is a GH Action in Typescript that shows it is quite straigtforward to get the ID and then use it: https://github.com/benc-uk/workflow-dispatch/blob/7ff1caf33291d1ed4001bebfa7342d5ad77eb3bf/src/main.ts#L24-L46

@janpio janpio added kind/improvement An improvement to existing feature and code. topic: ci labels Jul 31, 2020
@janpio janpio added this to the 2.4.0 milestone Jul 31, 2020
@mavilein mavilein added the tech/engines Issue for tech Engines. label Aug 4, 2020
@mavilein mavilein added the tech/engines/other Issue in the engines repo that does not fit one of the other labels. label Aug 4, 2020
@janpio janpio modified the milestones: 2.4.0, Backlog 2.5.0 Aug 4, 2020
@carmenberndt
Copy link
Contributor

A bit effort is that it requires the workflow_id as a param on the API: https://docs.github.com/en/rest/reference/actions#create-a-workflow-dispatch-event

The workflow_id is not needed, it can be replaced with the workflow file name.

@pantharshit00
Copy link
Contributor

pantharshit00 commented Aug 5, 2020

It is quite easy to do, I did it for out stale action here:

https://github.com/prisma/prisma/blob/7d36455d7304ad7b998c9e314c063aed965732e0/.github/workflows/label-stale-issues.yml#L5

For API as @carmenberndt pointed out file works! It just need the ref which is a branch name or commit to work on:

image

(Example request that I used in insomnia)

@janpio
Copy link
Member Author

janpio commented Aug 5, 2020

@mavilein mavilein self-assigned this Aug 6, 2020
@mavilein
Copy link
Member

implemented in:
#1008
https://github.com/prisma/engineer/pull/15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/improvement An improvement to existing feature and code. tech/engines/other Issue in the engines repo that does not fit one of the other labels. tech/engines Issue for tech Engines. topic: ci
Projects
None yet
Development

No branches or pull requests

5 participants