103 Commits

Author SHA1 Message Date
Peter Evans
ce5485de42 Merge pull request #51 from peter-evans/not-found-error
Improve error message for 404 errors
2020-11-11 16:12:02 +09:00
Peter Evans
eed51ed4c3 Improve error message for 404 errors 2020-11-11 16:09:35 +09:00
Peter Evans
938c2224dd Merge pull request #46 from peter-evans/update-dependencies
Update dependencies
2020-11-11 15:45:07 +09:00
actions-bot
d1b7bfe3a6 Update dependencies 2020-11-05 01:11:15 +00:00
Peter Evans
8031fbaca8 Merge pull request #48 from peter-evans/update-distribution
Update distribution
2020-10-02 15:16:49 +09:00
peter-evans
f1680f525a Update distribution 2020-10-02 06:09:25 +00:00
Peter Evans
5fda2f7d98 Merge pull request #47 from peter-evans/dependabot/npm_and_yarn/actions/core-1.2.6
Bump @actions/core from 1.2.5 to 1.2.6
2020-10-02 15:07:56 +09:00
dependabot[bot]
031f27b115 Bump @actions/core from 1.2.5 to 1.2.6
Bumps [@actions/core](https://github.com/actions/toolkit/tree/HEAD/packages/core) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/actions/toolkit/releases)
- [Changelog](https://github.com/actions/toolkit/blob/main/packages/core/RELEASES.md)
- [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/core)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-01 17:24:37 +00:00
Peter Evans
c49e1666ac Merge pull request #44 from staabm/patch-1
Mention string length limitations
2020-09-24 11:08:22 +09:00
Markus Staab
111788c696 Update README.md 2020-09-24 11:05:07 +09:00
Markus Staab
f131b1d1f9 Update README.md 2020-09-24 11:05:07 +09:00
Peter Evans
95531d6358 Merge pull request #45 from peter-evans/update-distribution
Update distribution
2020-09-22 08:56:42 +09:00
peter-evans
b4caad9acd Update distribution 2020-09-21 23:56:30 +00:00
Peter Evans
543acfac4e Merge pull request #37 from peter-evans/update-dependencies
Update dependencies
2020-09-22 08:55:27 +09:00
Markus Staab
1b0d3fa47b Update README.md 2020-09-19 07:59:30 +02:00
Markus Staab
6de120f0ca Update README.md 2020-09-19 07:58:31 +02:00
Markus Staab
1f8e017ab8 Mention string length limitations 2020-09-19 07:56:36 +02:00
actions-bot
4e1995c760 Update dependencies 2020-09-17 01:13:09 +00:00
Peter Evans
7d5ca7bf80 Merge pull request #43 from peter-evans/update-distribution
Update distribution
2020-09-13 15:09:49 +09:00
peter-evans
618fe4e18f Update distribution 2020-09-13 06:08:13 +00:00
Peter Evans
8f8aeefe6e Merge pull request #42 from peter-evans/dependabot/npm_and_yarn/node-fetch-2.6.1
Bump node-fetch from 2.6.0 to 2.6.1
2020-09-13 15:06:51 +09:00
dependabot[bot]
c5318edea4 Bump node-fetch from 2.6.0 to 2.6.1
Bumps [node-fetch](https://github.com/bitinn/node-fetch) from 2.6.0 to 2.6.1.
- [Release notes](https://github.com/bitinn/node-fetch/releases)
- [Changelog](https://github.com/node-fetch/node-fetch/blob/master/docs/CHANGELOG.md)
- [Commits](https://github.com/bitinn/node-fetch/compare/v2.6.0...v2.6.1)

Signed-off-by: dependabot[bot] <support@github.com>
2020-09-12 10:25:06 +00:00
Peter Evans
438514a476 Merge pull request #41 from peter-evans/update-ncc
Update ncc
2020-08-22 15:29:58 +09:00
Peter Evans
216dea92e3 Update ncc 2020-08-22 15:28:17 +09:00
Peter Evans
c0fe68ba01 Update readme 2020-08-04 15:54:46 +09:00
Peter Evans
21c5610af0 Update slash-command-dispatch to v2 2020-07-25 13:45:08 +09:00
Peter Evans
754562405e Update create-pull-request action to v3 2020-07-23 16:05:30 +09:00
Peter Evans
a12578c2e0 Merge pull request #36 from peter-evans/dependabot/npm_and_yarn/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19
2020-07-20 17:43:59 +09:00
dependabot[bot]
0e075ee1a0 Bump lodash from 4.17.15 to 4.17.19
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-20 08:41:32 +00:00
Peter Evans
3b28b4b04f Merge pull request #35 from peter-evans/update-distribution
Update distribution
2020-07-19 18:06:42 +09:00
peter-evans
9e58632f8a Update distribution 2020-07-19 09:06:12 +00:00
Peter Evans
163f36102f Merge pull request #30 from peter-evans/update-dependencies
Update dependencies
2020-07-19 18:04:45 +09:00
actions-bot
4532a8fb51 Update dependencies 2020-07-16 01:05:50 +00:00
Peter Evans
f540f114fd Update readme 2020-06-25 09:13:39 +09:00
Peter Evans
1c51dc3383 Merge pull request #31 from cbetta/patch-1
Clarify that PAT owner needs to have repo access
2020-06-25 09:12:02 +09:00
Cristiano Betta
8e9f439e9f Clarify that PAT owner needs to have repo access
Ran into an issue where I was using a user that did not have explicit access to the repo that I was trying to trigger an event for. I'm not sure if the user needs write access to the repo, but it seems logical to me that someone with `read` only access can not trigger GH actions.
2020-06-24 14:57:02 +01:00
Peter Evans
1708dda570 Merge pull request #27 from peter-evans/update-dependencies
Update dependencies
2020-06-04 15:28:27 +09:00
Peter Evans
eb329a2e6a Fix for github v3 2020-06-04 15:25:58 +09:00
actions-bot
7aa158e97c Update dependencies 2020-06-04 01:05:19 +00:00
Peter Evans
35f05e8e06 Fix ci artifacts 2020-06-02 18:37:55 +09:00
Peter Evans
f0c6ad7fa3 Fix prettier glob pattern 2020-06-02 18:37:38 +09:00
Peter Evans
fe5946ba71 Update slash command dispatch 2020-06-02 18:37:24 +09:00
Peter Evans
7ecf080487 Update README 2020-05-29 10:21:14 +09:00
Peter Evans
c830a9705e Update README 2020-05-25 18:16:20 +09:00
Peter Evans
ed97383570 Add rebase slash command 2020-05-25 17:30:29 +09:00
Peter Evans
b410ea76d1 Skip test job for pull requests from forks 2020-05-13 17:23:47 +09:00
Peter Evans
7fe6653bc4 Merge pull request #26 from peter-evans/update-distribution
Update distribution
2020-05-13 11:41:29 +09:00
peter-evans
d874befdda Update distribution 2020-05-13 02:41:01 +00:00
Peter Evans
9f64758ff8 Merge pull request #25 from peter-evans/update-dependencies
Update dependencies
2020-05-13 11:39:27 +09:00
actions-bot
e42b4b7b55 Update dependencies 2020-05-07 01:03:09 +00:00
Peter Evans
cb588ee63a Ignore documentation paths 2020-05-06 11:41:48 +09:00
Peter Evans
41bdbb0627 Add update dependencies workflow 2020-05-06 10:00:17 +09:00
Renovate Bot
d47934dfd8 Update dependency @types/node to v13.13.5 2020-05-05 21:45:53 +00:00
Renovate Bot
34d557382e Update jest monorepo to v26.0.1 2020-05-05 12:45:41 +00:00
Peter Evans
a4bb1fc8bc Add ci badge 2020-05-05 14:11:28 +09:00
Peter Evans
f9ec82f96b Update input description 2020-05-05 09:17:05 +09:00
Renovate Bot
56cbd49233 Update jest monorepo to v26 2020-05-04 20:20:12 +00:00
Renovate Bot
16c8fb978c Update dependency @typescript-eslint/parser to v2.31.0 2020-05-04 18:37:46 +00:00
Renovate Bot
f907bfd540 Update dependency eslint-plugin-jest to v23.9.0 2020-05-04 16:23:15 +00:00
Peter Evans
d1c3069352 Merge pull request #19 from peter-evans/update-distribution
Update distribution
2020-05-04 18:29:25 +09:00
peter-evans
dbeec545b7 Update distribution 2020-05-04 09:28:59 +00:00
Peter Evans
cfd43c3b5b Merge pull request #18 from peter-evans/typescript
Typescript
2020-05-04 18:27:31 +09:00
Peter Evans
ac8b848f7a Fix workflow 2020-05-04 18:20:48 +09:00
Peter Evans
3d4567b16c Update README 2020-05-04 18:20:48 +09:00
Peter Evans
0bda5274a2 Update workflows 2020-05-04 18:20:48 +09:00
Peter Evans
afd1745cdd Update action.yml 2020-05-04 18:20:48 +09:00
Peter Evans
176e52d27a Convert to Typescript 2020-05-04 18:20:48 +09:00
Peter Evans
ac6d1df23c Update gitignore 2020-05-04 18:20:48 +09:00
Peter Evans
48f2af69f2 Add jest config 2020-05-04 18:20:48 +09:00
Peter Evans
e5b7800e31 Add prettier config 2020-05-04 18:20:48 +09:00
Peter Evans
5065953cb1 Update eslint config 2020-05-04 18:20:48 +09:00
Peter Evans
8f68ab9db2 Update workflow 2020-05-04 18:20:33 +09:00
Peter Evans
c1daf2a5ee Merge pull request #17 from peter-evans/ci-fix
Fix CI workflow
2020-05-03 11:37:59 +09:00
Peter Evans
2c6e6ad52e Fix ci workflow 2020-05-03 11:30:33 +09:00
Peter Evans
ac04beb74d Merge pull request #14 from peter-evans/update-distribution
Update distribution
2020-05-02 21:58:08 +09:00
peter-evans
4c932e5fcf Update distribution 2020-05-02 10:28:15 +00:00
Peter Evans
c3983458b8 Merge pull request #15 from peter-evans/renovate/octokit-request-5.x
Update dependency @octokit/request to v5.4.2
2020-05-02 19:26:26 +09:00
Renovate Bot
0273c20a19 Update dependency jest to v25.5.4 2020-05-02 10:15:46 +00:00
Renovate Bot
c18d89812d Update dependency @octokit/request to v5.4.2 2020-05-02 09:37:58 +00:00
Peter Evans
87c9d703ce Merge pull request #13 from peter-evans/renovate/actions-core-1.x
Update dependency @actions/core to v1.2.4
2020-05-02 17:37:31 +09:00
Renovate Bot
79ebb27197 Update dependency @actions/core to v1.2.4 2020-05-02 08:28:23 +00:00
Peter Evans
070f6e1940 Merge pull request #12 from peter-evans/ci
Add CI workflow
2020-05-02 17:28:03 +09:00
Peter Evans
80521239f3 Add ci workflow 2020-05-02 17:25:16 +09:00
Peter Evans
22b027c6f6 Update README 2020-04-13 10:05:30 +09:00
Peter Evans
aa63154642 Merge pull request #11 from peter-evans/renovate/zeit-ncc-0.x
Update dependency @zeit/ncc to v0.22.1
2020-04-06 09:11:16 +09:00
Renovate Bot
fa5ce5b708 Update dependency @zeit/ncc to v0.22.1 2020-04-05 20:31:47 +00:00
Peter Evans
0aa5a24ce3 Merge pull request #9 from peter-evans/renovate/zeit-ncc-0.x
Update dependency @zeit/ncc to v0.22.0
2020-03-24 09:21:53 +09:00
Renovate Bot
22de67cbcd Update dependency @zeit/ncc to v0.22.0 2020-03-23 22:31:30 +00:00
Peter Evans
1e4d1b6ee6 Update README 2020-03-06 11:34:24 +09:00
Peter Evans
30e4e3c61c Merge pull request #6 from peter-evans/renovate/zeit-ncc-0.x
Update dependency @zeit/ncc to v0.21.1
2020-02-13 10:00:19 +09:00
Renovate Bot
8b55117fd3 Update dependency @zeit/ncc to v0.21.1 2020-02-12 16:54:07 +00:00
Peter Evans
cee9e0a8c3 Merge pull request #4 from peter-evans/renovate/zeit-ncc-0.x
Update dependency @zeit/ncc to v0.21.0
2020-01-05 08:07:49 +09:00
Renovate Bot
969582a5eb Update dependency @zeit/ncc to v0.21.0 2020-01-04 15:44:56 +00:00
Peter Evans
c8b367eb2d Update to checkout v2 2020-01-04 09:36:01 +09:00
Peter Evans
dd94f75873 Change script build to package 2020-01-04 09:35:47 +09:00
Peter Evans
23c9cd4b68 Update README 2019-12-05 01:18:06 +09:00
Peter Evans
bd127af08d Update workflow 2019-12-05 01:18:00 +09:00
Peter Evans
ee6a038929 Update README 2019-11-13 23:26:52 +09:00
Peter Evans
aaad5096a7 Update README 2019-11-11 23:35:49 +09:00
Peter Evans
6f1fae5558 Merge pull request #2 from peter-evans/renovate/pin-dependencies
Pin dependency @zeit/ncc to 0.20.5
2019-11-10 09:40:47 +09:00
Renovate Bot
72ff22d22a Pin dependency @zeit/ncc to 0.20.5 2019-11-10 00:40:01 +00:00
Peter Evans
01c2a6f449 Merge pull request #1 from peter-evans/renovate/configure
Configure Renovate
2019-11-10 09:39:44 +09:00
Renovate Bot
5e5f450278 Add renovate.json 2019-11-10 00:35:15 +00:00
19 changed files with 14243 additions and 4475 deletions

3
.eslintignore Normal file
View File

@@ -0,0 +1,3 @@
dist/
lib/
node_modules/

19
.eslintrc.json Normal file
View File

@@ -0,0 +1,19 @@
{
"env": { "node": true, "jest": true },
"parser": "@typescript-eslint/parser",
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"plugin:prettier/recommended",
"prettier/@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/camelcase": "off"
}
}

89
.github/workflows/ci.yml vendored Normal file
View File

@@ -0,0 +1,89 @@
name: CI
on:
push:
branches: [master]
paths-ignore:
- 'README.md'
- 'docs/**'
pull_request:
branches: [master]
paths-ignore:
- 'README.md'
- 'docs/**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.x
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm run lint
- run: npm run test
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist
- uses: actions/upload-artifact@v2
with:
name: action.yml
path: action.yml
test:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
needs: [build]
runs-on: ubuntu-latest
strategy:
matrix:
target: [built, committed]
steps:
- uses: actions/checkout@v2
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v2
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v2
with:
name: action.yml
path: .
- name: Test repository dispatch
uses: ./
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: tests
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
- name: Test repository dispatch (default payload)
uses: ./
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: tests
package:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update distribution
title: Update distribution
body: |
- Updates the distribution for changes on `master`
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-distribution

View File

@@ -1,13 +0,0 @@
name: Create Repository Dispatch
on: push
jobs:
createRepositoryDispatch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Repository Dispatch
uses: ./
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: tests
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

View File

@@ -3,10 +3,17 @@ on:
repository_dispatch:
types: [tests]
jobs:
autopep8:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Dump the client payload context
env:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"
- uses: actions/checkout@v2
if: github.event.client_payload.ref != ''
with:
ref: ${{ github.event.client_payload.ref }}
- run: echo ${{ github.event.client_payload.sha }}

View File

@@ -0,0 +1,21 @@
name: Slash Command Dispatch
on:
issue_comment:
types: [created]
jobs:
slashCommandDispatch:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v2
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
config: >
[
{
"command": "rebase",
"permission": "admin",
"repository": "peter-evans/slash-command-dispatch-processor",
"issue_type": "pull-request"
}
]

31
.github/workflows/update-dep.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Update Dependencies
on:
schedule:
- cron: '0 1 * * 4'
jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Update dependencies
run: |
npx -p npm-check-updates ncu -u
npm install
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
commit-message: Update dependencies
committer: GitHub <noreply@github.com>
author: actions-bot <actions-bot@users.noreply.github.com>
title: Update dependencies
body: |
- Dependency updates
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-dependencies

3
.gitignore vendored
View File

@@ -1 +1,2 @@
node_modules
lib/
node_modules/

3
.prettierignore Normal file
View File

@@ -0,0 +1,3 @@
dist/
lib/
node_modules/

11
.prettierrc.json Normal file
View File

@@ -0,0 +1,11 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid",
"parser": "typescript"
}

View File

@@ -1,4 +1,5 @@
# Repository Dispatch
[![CI](https://github.com/peter-evans/repository-dispatch/workflows/CI/badge.svg)](https://github.com/peter-evans/repository-dispatch/actions?query=workflow%3ACI)
[![GitHub Marketplace](https://img.shields.io/badge/Marketplace-Repository%20Dispatch-blue.svg?colorA=24292e&colorB=0366d6&style=flat&longCache=true&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAM6wAADOsB5dZE0gAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAERSURBVCiRhZG/SsMxFEZPfsVJ61jbxaF0cRQRcRJ9hlYn30IHN/+9iquDCOIsblIrOjqKgy5aKoJQj4O3EEtbPwhJbr6Te28CmdSKeqzeqr0YbfVIrTBKakvtOl5dtTkK+v4HfA9PEyBFCY9AGVgCBLaBp1jPAyfAJ/AAdIEG0dNAiyP7+K1qIfMdonZic6+WJoBJvQlvuwDqcXadUuqPA1NKAlexbRTAIMvMOCjTbMwl1LtI/6KWJ5Q6rT6Ht1MA58AX8Apcqqt5r2qhrgAXQC3CZ6i1+KMd9TRu3MvA3aH/fFPnBodb6oe6HM8+lYHrGdRXW8M9bMZtPXUji69lmf5Cmamq7quNLFZXD9Rq7v0Bpc1o/tp0fisAAAAASUVORK5CYII=)](https://github.com/marketplace/actions/repository-dispatch)
A GitHub action to create a repository dispatch event.
@@ -7,18 +8,26 @@ A GitHub action to create a repository dispatch event.
```yml
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1.0.0
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: my-event
```
## Parameters
### Action inputs
- `token` (**required**) - A `repo` scoped GitHub [Personal Access Token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line).
- `repository` - The full name of the repository to send the dispatch. Defaults to the current repository.
- `event-type` (**required**) - A custom webhook event name.
- `client-payload` - JSON payload with extra information about the webhook event that your action or worklow may use. Default: {}
| Name | Description | Default |
| --- | --- | --- |
| `token` | (**required**) A `repo` scoped GitHub [Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token). See [token](#token) for further details. | |
| `repository` | The full name of the repository to send the dispatch. | `github.repository` (current repository) |
| `event-type` | (**required**) A custom webhook event name. | |
| `client-payload` | JSON payload with extra information about the webhook event that your action or workflow may use. | `{}` |
#### `token`
This action creates [`repository_dispatch`](https://developer.github.com/v3/repos/#create-a-repository-dispatch-event) events.
The default `GITHUB_TOKEN` does not have scopes to do this so a `repo` scoped [PAT](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) created on a user with `write` access to the target repository is required.
If you will be dispatching to a public repository then you can use the more limited `public_repo` scope.
## Example
@@ -26,7 +35,7 @@ Here is an example setting all of the input parameters.
```yml
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1.0.0
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: username/my-repo
@@ -35,6 +44,7 @@ Here is an example setting all of the input parameters.
```
Here is an example `on: repository_dispatch` workflow to receive the event.
Note that repository dispatch events will only trigger a workflow run if the workflow is committed to the default branch (usually `master`).
```yml
name: Repository Dispatch
@@ -42,15 +52,63 @@ on:
repository_dispatch:
types: [my-event]
jobs:
autopep8:
myEvent:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
with:
ref: ${{ github.event.client_payload.ref }}
- run: echo ${{ github.event.client_payload.sha }}
```
### Dispatch to multiple repositories
You can dispatch to multiple repositories by using a [matrix strategy](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix). In the following example, after the `build` job succeeds, an event is dispatched to three different repositories.
```yml
jobs:
build:
# Main workflow job that builds, tests, etc.
dispatch:
needs: build
strategy:
matrix:
repo: ['my-org/repo1', 'my-org/repo2', 'my-org/repo3']
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: ${{ matrix.repo }}
event-type: my-event
```
## Client payload
The GitHub API allows a maximum of 10 top-level properties in the `client-payload` JSON.
If you use more than that you will see an error message like the following.
```
No more than 10 properties are allowed; 14 were supplied.
```
For example, this payload will fail because it has more than 10 top-level properties.
```yml
client-payload: ${{ toJson(github) }}
```
To solve this you can simply wrap the payload in a single top-level property.
The following payload will succeed.
```yml
client-payload: '{"github": ${{ toJson(github) }}}'
```
Additionally, there is a limitation on the total data size of the `client-payload`. A very large payload may result in a `client_payload is too large` error.
## License
[MIT](LICENSE)

View File

@@ -5,16 +5,17 @@ inputs:
description: 'A repo scoped GitHub Personal Access Token'
required: true
repository:
description: 'The full name of the repository to send the dispatch. Defaults to the current repository.'
description: 'The full name of the repository to send the dispatch.'
default: ${{ github.repository }}
event-type:
description: 'A custom webhook event name.'
required: true
client-payload:
description: 'JSON payload with extra information about the webhook event that your action or worklow may use. Default: {}'
description: 'JSON payload with extra information about the webhook event that your action or worklow may use.'
default: '{}'
runs:
using: 'node12'
main: 'dist/index.js'
branding:
icon: 'target'
icon: 'target'
color: 'gray-dark'

11850
dist/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,40 +0,0 @@
const { inspect } = require("util");
const core = require("@actions/core");
const { request } = require("@octokit/request");
async function run() {
try {
const inputs = {
token: core.getInput("token"),
repository: core.getInput("repository"),
eventType: core.getInput("event-type"),
clientPayload: core.getInput("client-payload")
};
core.debug(`Inputs: ${inspect(inputs)}`);
const repository = inputs.repository ? inputs.repository : process.env.GITHUB_REPOSITORY;
core.debug(`repository: ${repository}`);
const clientPayload = inputs.clientPayload ? inputs.clientPayload : '{}';
core.debug(`clientPayload: ${clientPayload}`);
await request(
`POST /repos/${repository}/dispatches`,
{
headers: {
authorization: `token ${inputs.token}`
},
mediaType: {
previews: ['everest']
},
event_type: `${inputs.eventType}`,
client_payload: JSON.parse(clientPayload),
}
);
} catch (error) {
core.debug(inspect(error));
core.setFailed(error.message);
}
}
run();

11
jest.config.js Normal file
View File

@@ -0,0 +1,11 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testEnvironment: 'node',
testMatch: ['**/*.test.ts'],
testRunner: 'jest-circus/runner',
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

6442
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,25 @@
{
"name": "repository-dispatch",
"version": "1.0.0",
"private": true,
"description": "Create a repository dispatch event",
"main": "index.js",
"main": "lib/main.js",
"scripts": {
"build": "ncc build index.js -o dist"
"build": "tsc && ncc build",
"format": "prettier --write '**/*.ts'",
"format-check": "prettier --check '**/*.ts'",
"lint": "eslint src/**/*.ts",
"test": "jest --passWithNoTests"
},
"repository": {
"type": "git",
"url": "git+https://github.com/peter-evans/repository-dispatch.git"
},
"keywords": [],
"keywords": [
"actions",
"repository",
"dispatch"
],
"author": "Peter Evans",
"license": "MIT",
"bugs": {
@@ -18,10 +27,22 @@
},
"homepage": "https://github.com/peter-evans/repository-dispatch#readme",
"dependencies": {
"@actions/core": "^1.1.1",
"@octokit/request": "^5.1.0"
"@actions/core": "1.2.6",
"@actions/github": "4.0.0"
},
"devDependencies": {
"@zeit/ncc": "^0.20.5"
"@types/jest": "26.0.15",
"@types/node": "14.14.6",
"@typescript-eslint/parser": "4.6.1",
"@vercel/ncc": "0.24.1",
"eslint": "7.12.1",
"eslint-plugin-github": "4.1.1",
"eslint-plugin-jest": "24.1.0",
"jest": "26.6.3",
"jest-circus": "26.6.3",
"js-yaml": "3.14.0",
"prettier": "2.1.2",
"ts-jest": "26.4.3",
"typescript": "4.0.5"
}
}

37
src/main.ts Normal file
View File

@@ -0,0 +1,37 @@
import * as core from '@actions/core'
import * as github from '@actions/github'
import {inspect} from 'util'
async function run(): Promise<void> {
try {
const inputs = {
token: core.getInput('token'),
repository: core.getInput('repository'),
eventType: core.getInput('event-type'),
clientPayload: core.getInput('client-payload')
}
core.debug(`Inputs: ${inspect(inputs)}`)
const [owner, repo] = inputs.repository.split('/')
const octokit = github.getOctokit(inputs.token)
await octokit.repos.createDispatchEvent({
owner: owner,
repo: repo,
event_type: inputs.eventType,
client_payload: JSON.parse(inputs.clientPayload)
})
} catch (error) {
core.debug(inspect(error))
if (error.status == 404) {
core.setFailed(
'Repository not found, OR token has insufficient permissions.'
)
} else {
core.setFailed(error.message)
}
}
}
run()

16
tsconfig.json Normal file
View File

@@ -0,0 +1,16 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"lib": [
"es6"
],
"outDir": "./lib",
"rootDir": "./src",
"declaration": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true
},
"exclude": ["__test__", "lib", "node_modules"]
}