-
Hello! Do you have any plans to extend Github Actions API to have a possibility to run a workflow and pass some parameters/environment variables? Actually, what I need badly is something similar to the https://docs.drone.io/promote/ Such API allows us to write CLI tool to run workflows. I understand that this is a complicated task, because we need to have some new type of event to trigger workflows, let say, promotion event and also it will extend the context of workflow. Real-life scenario for such thing I have a feature branch and write some code in it. But sometimes I want to deploy my code to some kind of staging environment. What can I do in this situations? Currently I have the separate workflow with jobs.if-condition statement in it which checks the text [deploy-staging] in the commit message, but it is awful solution. The promotion event could solve my problem, because I will use it only when I ready to deploy my code somewhere. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I think repository_dispatch events might provide the functionality that you’re looking for. It sounds like you’d want to clearly define your types and the necessary payload for the type, and then add those add types in the workflow triggers block. |
Beta Was this translation helpful? Give feedback.
-
I’ve just come off of a small project where we used manually-triggered workflows for things like deploys and database migrations, and our workflow looked something like this:
This workflow will run on the “repository_dispatch” event when the type is “db-migrate”—there are also other expected payload values such as “direction”, “count”, and “env” which dictated various aspects of our migrations. I wrote a small tool, dpx, whose purpose it is to make sending these dispatch events easier:
Since you asked, you could also set environment variables using this, if need be:
See the ::set-env documentation for more info on that, but the idea is that we’re setting an environment variable whose value is something provided in the repository dispatch payload. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for pointing me on this event. I missed it. It looks like what I needed. |
Beta Was this translation helpful? Give feedback.
-
Thank you for sharing your CLI tool and workflow examples! |
Beta Was this translation helpful? Give feedback.
I think repository_dispatch events might provide the functionality that you’re looking for. It sounds like you’d want to clearly define your types and the necessary payload for the type, and then add those add types in the workflow triggers block.
https://help.github.com/en/actions/reference/events-that-trigger-workflows#external-events-repository_dispatch