So what I ended up doing to make it work per @GuiFalourd comment was to move payload generation into it's own step like so:
- name: Create JSON Payload
run: echo "JSON_PAYLOAD={\"Name\":\"${{ env.BRANCH_NAME }}\"}" >> $GITHUB_ENV
and use it further down like this:
Payload: ${{ env.JSON_PAYLOAD }}
you should use double curly brace, instead of
Payload: '{"Name": "${env.BRANCH_NAME}" }'
use
Payload: '{"Name": "${{env.BRANCH_NAME}" }}'
you don't need an extra step to build the payload
UPDATE
Seems the issue is the env definition in the env section: moving the var definition in a dedicated step will solve the problem. Of course this solution is similar to build the payload in a dedicated step. See this PR https://github.com/mbiagetti/github-action-poc/pull/4/files
To get event data, you can use a GitHub action to print the event to the log.
# change this to the event type you want to get the data for
on:
pull_request:
types: [opened, closed, reopened]
jobs:
printJob:
name: Print event
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
Alternatively, you can find example event data in the documentation: https://docs.github.com/en/developers/webhooks-and-events/webhook-events-and-payloads#webhook-payload-example-30
How to use an event.json file locally with nektos/act from their documentation they describe structure like:
# File: /path/to/event.json
{
"pull_request": {
"head": {
"ref": "sample-head-ref"
},
"base": {
"ref": "sample-base-ref"
}
}
}
Or follow steps in answer above to have github output the action event details and paste into this event.json file
Then to use the event file locally you can add the option --eventpath '/path/to/event.json' to your run act command, example:
act -W '.github/workflows/run_this_workflow.yml' -s GITHUB_TOKEN="$(gh auth token)" --eventpath '/path/to/event.json'