This example target provides a command-line interface for sending a webhook event to a GitHub Actions workflow.
This example should always be executed from inside this directory (since it searches for a configuration file here).
At the end of this quick start, you should be able to receive your arbitrary payload in a GitHub Actions workflow in your own repository, like below:
- In this directory, copy
config.example.yaml
toconfig.yaml
- Create a GitHub App in your account (alternatively use an existing app you have already created)
- The only values you need to fill in is the app name and URL (which can be your GitHub profile URL), and you can uncheck
Active
underWebhook
- Under
Repository permissions
, thenContents
, grantRead and write
permissions (this allows invoking an Actions webhook)
- The only values you need to fill in is the app name and URL (which can be your GitHub profile URL), and you can uncheck
- After successful creation, copy the
App ID
value and replace the example value for the keyappId
inconfig.yaml
- At the bottom of the same page, under
Private keys
, generate a private key for your app - Open the generated and downloaded
.pem
file in a text editor, copy the entire contents, and replace the example value for the keyprivateKey
inconfig.yaml
- Create a new example repository at which to receive your webhook (alternatively reuse an existing repo you have already created)
- Copy the repository name and replace the example value for the key
repository
inconfig.yaml
- Install your new app on your example repository
- After successful installation, copy the username of the user or organization you installed the app on and replace the example value for the key
username
inconfig.yaml
- Copy the file
print-payload.yaml
to your example repository, at the path.github/workflows/print-payload.yaml
, then commit and push the changes
Here are some example commands for sending messages or showing help information about the CLI:
swift run GithubActionsWebhookClient < payload.example.json
: send the exact example payload shown aboveswift run GithubActionsWebhookClient --help
: print the CLI's help messages (which show what values can be configured)swift run GithubActionsWebhookClient < {path/to/payload}.json
: send your own payload fileswift run GithubActionsWebhookClient --payload path/to/payload.json
: send your own payload file, without using shell redirection