Skip to content

Commit

Permalink
feat: initial commit 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Di Benedetto committed Dec 31, 2020
0 parents commit 7cd09bd
Show file tree
Hide file tree
Showing 13 changed files with 9,920 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
coverage
20 changes: 20 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: [
'@typescript-eslint',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
],
rules: {
// disable semicolon
'@typescript-eslint/member-delimiter-style': 'off',
// allow use of 'any'
'@typescript-eslint/no-explicit-any': 'off',
// allow explicit type declarations
'@typescript-eslint/no-inferrable-types': 'off'
}
}
16 changes: 16 additions & 0 deletions .github/workflows/.github/workflows/ci-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI for Repository Dispatch

on:
repository_dispatch:
types: ['test_dispatch']

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Show received client_payload
env:
CLIENT_PAYLOAD: ${{ toJson(github.event.client_payload) }}
run: |
echo "Client Payload"
echo "$CLIENT_PAYLOAD"
24 changes: 24 additions & 0 deletions .github/workflows/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CI

# This event is triggered on pushes to master & PRs to all branches
on:
pull_request:
push:
branches:
- '*'

jobs:
self-test:
name: Self Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Cloning repository

- uses: ./
name: Dispatch Event
id: dispatch_action
with:
eventType: 'test_dispatch'
token: ${{ secrets.REPO_PAT }}
payload: '{"requested_by": "${{github.actor}}"}'
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
*.log
coverage
.nyc_output/

33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
![CI for Repository Dispatch](https://github.com/iniva/action-repository-dispatch/workflows/CI%20for%20Repository%20Dispatch/badge.svg)
![CI](https://github.com/iniva/action-repository-dispatch/workflows/CI/badge.svg)

# Action: Repository Dispatch <!-- omit in toc -->

- [Usage](#usage)
- [Inputs](#inputs)
- [(*) token](#-token)

# Usage
> :information_source: Check the [ci workflow](.github/workflows/ci.yml) in this repo to see a live example on how to use this action in your own workflow
## Inputs
- `targetRepository`: Full name (`owner/repo-name`) of the repository that will receive the `repository_dispatch` event.
- required: `false`
- default: `${{ github.repository }}` (current repository running the workflow)

- `eventType`: Custom event type expected by the receiving repository
- required: `true`
- example: `'do-something-awesome'`

- `token`: A GitHub Personal Access Token (PAT) ([more info](#-token))
- required: `true`

- `payload`: Stringified JSON payload
- required: `false`
- default: `'{}'`
- example: `'{"customField": "some value", "anotherField": "another value"}'`

### (*) token
:information_source: If you are targeting:
- **Public repository**: The PAT only needs `public_repo` scope
- **Private repository**: The PAT needs `repo` scope and its owner needs `write` access in the target repository
29 changes: 29 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Repository Dispatch
author: 'Tony DBR'
description: Send customized repository_dispatch events
branding:
color: red
icon: send

inputs:
targetRepository:
description: Full name (owner/repo-name) of the repository that will receive the repository_dispatch event
required: false
default: ${{ github.respository }}

eventType:
description: Custom event type expected by the receiving repository
required: true

token:
description: A GitHub Personal Access Token (PAT) with 'repo' permissions
required: true

payload:
description: Stringified JSON payload
required: false
default: '{}'

runs:
using: 'node12'
main: 'dist/index.js'
Loading

0 comments on commit 7cd09bd

Please sign in to comment.