mirror of
https://github.com/peter-evans/repository-dispatch.git
synced 2026-06-11 11:21:25 +00:00
Compare commits
103 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ce5485de42 | ||
|
|
eed51ed4c3 | ||
|
|
938c2224dd | ||
|
|
d1b7bfe3a6 | ||
|
|
8031fbaca8 | ||
|
|
f1680f525a | ||
|
|
5fda2f7d98 | ||
|
|
031f27b115 | ||
|
|
c49e1666ac | ||
|
|
111788c696 | ||
|
|
f131b1d1f9 | ||
|
|
95531d6358 | ||
|
|
b4caad9acd | ||
|
|
543acfac4e | ||
|
|
1b0d3fa47b | ||
|
|
6de120f0ca | ||
|
|
1f8e017ab8 | ||
|
|
4e1995c760 | ||
|
|
7d5ca7bf80 | ||
|
|
618fe4e18f | ||
|
|
8f8aeefe6e | ||
|
|
c5318edea4 | ||
|
|
438514a476 | ||
|
|
216dea92e3 | ||
|
|
c0fe68ba01 | ||
|
|
21c5610af0 | ||
|
|
754562405e | ||
|
|
a12578c2e0 | ||
|
|
0e075ee1a0 | ||
|
|
3b28b4b04f | ||
|
|
9e58632f8a | ||
|
|
163f36102f | ||
|
|
4532a8fb51 | ||
|
|
f540f114fd | ||
|
|
1c51dc3383 | ||
|
|
8e9f439e9f | ||
|
|
1708dda570 | ||
|
|
eb329a2e6a | ||
|
|
7aa158e97c | ||
|
|
35f05e8e06 | ||
|
|
f0c6ad7fa3 | ||
|
|
fe5946ba71 | ||
|
|
7ecf080487 | ||
|
|
c830a9705e | ||
|
|
ed97383570 | ||
|
|
b410ea76d1 | ||
|
|
7fe6653bc4 | ||
|
|
d874befdda | ||
|
|
9f64758ff8 | ||
|
|
e42b4b7b55 | ||
|
|
cb588ee63a | ||
|
|
41bdbb0627 | ||
|
|
d47934dfd8 | ||
|
|
34d557382e | ||
|
|
a4bb1fc8bc | ||
|
|
f9ec82f96b | ||
|
|
56cbd49233 | ||
|
|
16c8fb978c | ||
|
|
f907bfd540 | ||
|
|
d1c3069352 | ||
|
|
dbeec545b7 | ||
|
|
cfd43c3b5b | ||
|
|
ac8b848f7a | ||
|
|
3d4567b16c | ||
|
|
0bda5274a2 | ||
|
|
afd1745cdd | ||
|
|
176e52d27a | ||
|
|
ac6d1df23c | ||
|
|
48f2af69f2 | ||
|
|
e5b7800e31 | ||
|
|
5065953cb1 | ||
|
|
8f68ab9db2 | ||
|
|
c1daf2a5ee | ||
|
|
2c6e6ad52e | ||
|
|
ac04beb74d | ||
|
|
4c932e5fcf | ||
|
|
c3983458b8 | ||
|
|
0273c20a19 | ||
|
|
c18d89812d | ||
|
|
87c9d703ce | ||
|
|
79ebb27197 | ||
|
|
070f6e1940 | ||
|
|
80521239f3 | ||
|
|
22b027c6f6 | ||
|
|
aa63154642 | ||
|
|
fa5ce5b708 | ||
|
|
0aa5a24ce3 | ||
|
|
22de67cbcd | ||
|
|
1e4d1b6ee6 | ||
|
|
30e4e3c61c | ||
|
|
8b55117fd3 | ||
|
|
cee9e0a8c3 | ||
|
|
969582a5eb | ||
|
|
c8b367eb2d | ||
|
|
dd94f75873 | ||
|
|
23c9cd4b68 | ||
|
|
bd127af08d | ||
|
|
ee6a038929 | ||
|
|
aaad5096a7 | ||
|
|
6f1fae5558 | ||
|
|
72ff22d22a | ||
|
|
01c2a6f449 | ||
|
|
5e5f450278 |
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
19
.eslintrc.json
Normal file
19
.eslintrc.json
Normal 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
89
.github/workflows/ci.yml
vendored
Normal 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
|
||||
13
.github/workflows/create-repository-dispatch.yml
vendored
13
.github/workflows/create-repository-dispatch.yml
vendored
@@ -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 }}"}'
|
||||
11
.github/workflows/on-repository-dispatch.yml
vendored
11
.github/workflows/on-repository-dispatch.yml
vendored
@@ -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 }}
|
||||
|
||||
21
.github/workflows/slash-command-dispatch.yml
vendored
Normal file
21
.github/workflows/slash-command-dispatch.yml
vendored
Normal 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
31
.github/workflows/update-dep.yml
vendored
Normal 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
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
node_modules
|
||||
lib/
|
||||
node_modules/
|
||||
|
||||
3
.prettierignore
Normal file
3
.prettierignore
Normal file
@@ -0,0 +1,3 @@
|
||||
dist/
|
||||
lib/
|
||||
node_modules/
|
||||
11
.prettierrc.json
Normal file
11
.prettierrc.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"printWidth": 80,
|
||||
"tabWidth": 2,
|
||||
"useTabs": false,
|
||||
"semi": false,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"bracketSpacing": false,
|
||||
"arrowParens": "avoid",
|
||||
"parser": "typescript"
|
||||
}
|
||||
76
README.md
76
README.md
@@ -1,4 +1,5 @@
|
||||
# Repository Dispatch
|
||||
[](https://github.com/peter-evans/repository-dispatch/actions?query=workflow%3ACI)
|
||||
[](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)
|
||||
|
||||
@@ -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
11850
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
40
index.js
40
index.js
@@ -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
11
jest.config.js
Normal 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
6442
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
33
package.json
33
package.json
@@ -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
37
src/main.ts
Normal 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
16
tsconfig.json
Normal 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"]
|
||||
}
|
||||
Reference in New Issue
Block a user