Skip to content

Commit

Permalink
Initial implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Dec 24, 2020
1 parent ee7499d commit 3b9efd1
Show file tree
Hide file tree
Showing 12 changed files with 922 additions and 4,390 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dispatch Handler

on:
repository_dispatch:
type:
- ci

jobs:
dispatcher:
runs-on: ubuntu-latest

steps:
- name: Payload params
run: |
echo "Ref: ${{ github.event.client_payload.ref }}"
echo "Commit: ${{ github.event.client_payload.sha }}"
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Build and Test'
name: Build and Test

on:
pull_request:
Expand Down Expand Up @@ -28,3 +28,7 @@ jobs:
- uses: actions/checkout@v2
- id: action
uses: ./
with:
token: ${{ secrets.REPOSITORY_ACCESS_TOKEN }}
type: ci
payload: '{ "ref": "${{ github.ref }}", "sha": "${{ github.sha }}" }'
46 changes: 39 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,47 @@
# action_name
# Trigger repository_dispatch Action

Description.
Triggers a [`repository_dispatch`](https://docs.github.com/en/free-pro-team@latest/rest/reference/repos#create-a-repository-dispatch-event) event for the given repository.

## Inputs

*
| Name | Default | Required? | Description |
| --------- | ------------------- | --------- | ----------- |
| `token` | | **YES** | A [Personal Access Token](https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token) with `repo` scope |
| `repo` | `github.repository` | No | The name of the repository to send the event (`owner/repo`) |
| `type` | | **YES** | A custom webhook event name |
| `payload` | | No | JSON payload with extra information about the webhook event that your action or worklow may use. GitHub API allows for a maximum of 10 top-level properties |

## Outputs
## Example usage

*
In the workflow that needs to trigger a `repository_dispatch` action:

## Example usage
```yaml
- name: Repository Dispatch
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.REPOSITORY_ACCESS_TOKEN }}
repo: username/my-repo
type: my-custom-event
payload: '{ "ref": "${{ github.ref }}", "sha": "${{ github.sha }}" }'
```
A workflow that handles `repository_dispatch` action:

```yaml
name: Repository Dispatch
on:
repository_dispatch:
types:
- my-custom-event
jobs:
handle-dispatch:
runs-on: ubuntu-latest
steps:
- name: Print commit hash
run: echo ${{ github.event.client_payload.sha }}
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.ref }}
```
30 changes: 19 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
name: 'action-name'
description: 'Action description'
author: 'Myrotvorets'
#inputs:

#outputs:

name: Trigger Repository Dispatch
description: GitHub action to trigger a repository_dispatch event
author: Myrotvorets
inputs:
token:
description: A Personal Access Token with repo scope. Do not use GITHUB_TOKEN.
required: true
repo:
description: A repository (owner/repo) to send the dispatch to
required: false
type:
description: A custom webhook event name
required: true
payload:
description: An optional JSON payload with extra information about the webhook event that your action or worklow may use. Up to 10 top-level properties are allowed
required: false
runs:
using: 'node12'
main: 'dist/index.js'

#branding:
# color: blue
# icon: info
branding:
color: blue
icon: activity
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 3b9efd1

Please sign in to comment.