How to get my own github events payload json for testing github actions locally?

柔情痞子 提交于 2020-12-13 03:28:54

问题


I use github actions and want to test it locally. I'm using this tools and it works fine. https://github.com/nektos/act

I can provide a event.json for local testing, but it's really hard to create a real event payload.

Is there any way to get real event payload? For example, I create pull request on my repository from the console, and get that event payload json.


回答1:


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



来源:https://stackoverflow.com/questions/63803136/how-to-get-my-own-github-events-payload-json-for-testing-github-actions-locally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!