58 Commits

Author SHA1 Message Date
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
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
19 changed files with 11061 additions and 6701 deletions

3
.eslintignore Normal file
View File

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

View File

@@ -1,17 +1,19 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
}
}
"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"
}
}

View File

@@ -2,8 +2,14 @@ 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
@@ -13,14 +19,21 @@ jobs:
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
- run: npm run package
- 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:
@@ -33,14 +46,25 @@ jobs:
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: Repository Dispatch
- 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]
@@ -52,11 +76,9 @@ jobs:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v2
uses: peter-evans/create-pull-request@v3
with:
commit-message: Update distribution
committer: GitHub <noreply@github.com>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
title: Update distribution
body: |
- Updates the distribution for changes on `master`

View File

@@ -6,7 +6,14 @@ jobs:
tests:
runs-on: ubuntu-latest
steps:
- 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.
@@ -13,12 +14,20 @@ A GitHub action to create a repository dispatch event.
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 workflow 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
@@ -52,6 +61,30 @@ jobs:
- 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.

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'

11863
dist/index.js vendored

File diff suppressed because it is too large Load Diff

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
}

5556
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,25 @@
{
"name": "repository-dispatch",
"version": "1.0.0",
"private": true,
"description": "Create a repository dispatch event",
"main": "src/index.js",
"main": "lib/main.js",
"scripts": {
"lint": "eslint src/index.js",
"package": "ncc build src/index.js -o dist",
"test": "eslint src/index.js && jest --passWithNoTests"
"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": {
@@ -20,12 +27,22 @@
},
"homepage": "https://github.com/peter-evans/repository-dispatch#readme",
"dependencies": {
"@actions/core": "1.2.4",
"@octokit/request": "5.4.2"
"@actions/core": "1.2.5",
"@actions/github": "4.0.0"
},
"devDependencies": {
"@zeit/ncc": "0.22.1",
"eslint": "6.8.0",
"jest": "25.5.4"
"@types/jest": "26.0.14",
"@types/node": "14.10.3",
"@typescript-eslint/parser": "4.1.1",
"@vercel/ncc": "0.24.1",
"eslint": "7.9.0",
"eslint-plugin-github": "4.1.1",
"eslint-plugin-jest": "24.0.1",
"jest": "26.4.2",
"jest-circus": "26.4.2",
"js-yaml": "3.14.0",
"prettier": "2.1.2",
"ts-jest": "26.3.0",
"typescript": "4.0.2"
}
}

View File

@@ -1,11 +0,0 @@
{
"extends": [
"config:base"
],
"packageRules": [
{
"depTypeList": ["devDependencies"],
"automerge": true
}
]
}

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();

31
src/main.ts Normal file
View File

@@ -0,0 +1,31 @@
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))
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"]
}