How to pass parameters to Github Actions Workflow

hi folks

I have bunch of parameterized Jenkins jobs, saying before starting the build, the user can input the params for the job.

i’m looking for similar feature for Github Actions for our deployment job which listen on github deployment event.

for example, i’d like to allow user to be able to turn on/off some flags of the deployment, 

looks like the github deployment api support payload with any value like a json string: https://developer.github.com/v3/repos/deployments/#create-a-deployment

can the Github Actions receive that deployment payload and extract values for the workflow?

Hi @missedone , 

I am not sure whether I fully understood your requirement. Based on my understanding , you want github workflow to receive deployment evetnt payload and use the payload content in your workflow run. 

There is a github context for you to use which includes the deployment event payload.

And you could use ${{ }} syntax to get the value of json key value. Such as 

${{ github.event.deployment.environment }} 

There is an example of workflow yml to get environment name: 

name: deployment
on:
  deployment
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
     - name: Dump GitHub context
       env:
          GITHUB_CONTEXT: ${{ tojson(github) }}
          ENVIRONMENT: ${{ github.event.deployment.environment }}
       run: |
          echo "$GITHUB_CONTEXT"
          echo $ENVIRONMENT
2 Likes

right, i wasn’t aware of this, the github context works for me,

the payload can be any format, so i use jq in shell to extract the value:


DEPLOY\_PAYLOAD\_JSON='${{ github.event.deployment.payload }}'

echo $DEPLOY\_PAYLOAD\_JSON | jq -r \<the\_json\_path\>

thanks.