mirror of
https://github.com/peter-evans/repository-dispatch.git
synced 2026-06-23 20:55:53 +00:00
Compare commits
279 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf47d102fd | ||
|
|
c5deef1e22 | ||
|
|
8030323fd1 | ||
|
|
4d707c5166 | ||
|
|
8da7fdebab | ||
|
|
485f4e86a7 | ||
|
|
b33a54259e | ||
|
|
4a2a70e392 | ||
|
|
a7c9d19403 | ||
|
|
b1fb5fe34d | ||
|
|
6308d2f14d | ||
|
|
a940705449 | ||
|
|
b3490f1916 | ||
|
|
08864651bc | ||
|
|
caebe2a7c9 | ||
|
|
a9449a2234 | ||
|
|
9dfc4c14ae | ||
|
|
3dc273ab5e | ||
|
|
198d9e8b2d | ||
|
|
76b4bf08b2 | ||
|
|
69ae7288bd | ||
|
|
893c79884f | ||
|
|
da2ccb0fc8 | ||
|
|
4d042f3cdd | ||
|
|
a97598185a | ||
|
|
6b225e1d2f | ||
|
|
8b419274ed | ||
|
|
c945ae1ed9 | ||
|
|
211739d1dc | ||
|
|
64273c5e98 | ||
|
|
b6a62a01f9 | ||
|
|
6bf17eb4db | ||
|
|
27ec5d3cec | ||
|
|
75f14c1b20 | ||
|
|
f983f184f4 | ||
|
|
de82c064fb | ||
|
|
ee7b7aa21f | ||
|
|
02f5adb87b | ||
|
|
e7a1eba25a | ||
|
|
33c156812b | ||
|
|
bf21420db0 | ||
|
|
cc38e275b7 | ||
|
|
139d91f808 | ||
|
|
04fd37754d | ||
|
|
649322515e | ||
|
|
2190c43bfb | ||
|
|
bf59ed5d24 | ||
|
|
da1407e14b | ||
|
|
c559df9496 | ||
|
|
1ab431d693 | ||
|
|
beac760fe3 | ||
|
|
df88340924 | ||
|
|
4c03f6fcc3 | ||
|
|
dfe7e15033 | ||
|
|
819346bbe5 | ||
|
|
f2bc31c6b7 | ||
|
|
0939dad458 | ||
|
|
139c2f39af | ||
|
|
dec69ff3dd | ||
|
|
2b45b273ee | ||
|
|
25edde4367 | ||
|
|
10dd4dcec2 | ||
|
|
182a5c2a77 | ||
|
|
639e8363bb | ||
|
|
795fdbe3c9 | ||
|
|
c47b769ca8 | ||
|
|
eb67b04ead | ||
|
|
1c2365bf4d | ||
|
|
eb36a095e2 | ||
|
|
cca48d10e2 | ||
|
|
4bbd3f2e89 | ||
|
|
53ca819244 | ||
|
|
b9a653dc99 | ||
|
|
5c728bb088 | ||
|
|
b3d90c8630 | ||
|
|
418deffaa7 | ||
|
|
ca0f2f8cf9 | ||
|
|
c940693fd6 | ||
|
|
c48d233c43 | ||
|
|
fd1e0c2114 | ||
|
|
a03681cab3 | ||
|
|
e7b85aff61 | ||
|
|
de00547599 | ||
|
|
48f4b00257 | ||
|
|
a447c2a159 | ||
|
|
ea00f5770d | ||
|
|
a971e34b6d | ||
|
|
87c5425cae | ||
|
|
2eb43e8992 | ||
|
|
f8fc4e24e2 | ||
|
|
43c339a204 | ||
|
|
5acbb6da12 | ||
|
|
5df14b183c | ||
|
|
90286e0e44 | ||
|
|
a46c321bd0 | ||
|
|
4222f7b3d9 | ||
|
|
ca17d352ff | ||
|
|
afcf9605bc | ||
|
|
ab92c9cc83 | ||
|
|
714bf737ec | ||
|
|
b7052fc74c | ||
|
|
dc54a94bda | ||
|
|
e553c2b249 | ||
|
|
08947cd28e | ||
|
|
c2ab8b99f8 | ||
|
|
e03813e22c | ||
|
|
26b39ed245 | ||
|
|
b155cf1427 | ||
|
|
faa2bf022d | ||
|
|
0bc97bd4b8 | ||
|
|
8ab3ab850d | ||
|
|
defb7de2f3 | ||
|
|
fb1da2a91f | ||
|
|
ec896de369 | ||
|
|
9255d358ad | ||
|
|
f8e700e208 | ||
|
|
3c7e484edb | ||
|
|
cb18cc8cd6 | ||
|
|
1f873ff42d | ||
|
|
73f2fe9d70 | ||
|
|
9b60aa8a4d | ||
|
|
f2696244ec | ||
|
|
2f6d32ce83 | ||
|
|
66463e47e7 | ||
|
|
aebc169929 | ||
|
|
b700ade2f3 | ||
|
|
8e295bb3b1 | ||
|
|
b8601598d8 | ||
|
|
18c0a0eef4 | ||
|
|
870eb7a531 | ||
|
|
d591bcc413 | ||
|
|
42eb81b6bc | ||
|
|
26cb96aa5e | ||
|
|
6045f64a24 | ||
|
|
f8bc8c5c02 | ||
|
|
5e038d8e52 | ||
|
|
3c4e552d10 | ||
|
|
77fb463884 | ||
|
|
c8e633a77e | ||
|
|
e2dfd3c880 | ||
|
|
cac67678cf | ||
|
|
fe4ce16ccb | ||
|
|
6676414e8f | ||
|
|
eaded0e2ee | ||
|
|
23f37653ea | ||
|
|
c73dcc4242 | ||
|
|
3de81530cc | ||
|
|
d85250f54b | ||
|
|
4b2881efb9 | ||
|
|
c078548696 | ||
|
|
0459c47edf | ||
|
|
a275156cbd | ||
|
|
64c665535e | ||
|
|
077903f4f4 | ||
|
|
11ba7d3f32 | ||
|
|
646aa8008a | ||
|
|
8d9724ed37 | ||
|
|
88ec35d633 | ||
|
|
7fbda9c715 | ||
|
|
689b4c9c3d | ||
|
|
ecb27d1931 | ||
|
|
c9a37ac63b | ||
|
|
e006cbaf4a | ||
|
|
12751c0f0e | ||
|
|
3a8608a86b | ||
|
|
f3e2ad4d6d | ||
|
|
28a41e5d3f | ||
|
|
59fb538f54 | ||
|
|
6b9355a6b3 | ||
|
|
0e8ca8c8a5 | ||
|
|
1d7df303a4 | ||
|
|
48ba398488 | ||
|
|
a3b37769d2 | ||
|
|
6c67f6dc34 | ||
|
|
c66206b38f | ||
|
|
5e4869cf56 | ||
|
|
a691d185a6 | ||
|
|
2694ce6b01 | ||
|
|
d7bf02a0d4 | ||
|
|
f43d2e4f9b | ||
|
|
0e60b0b03e | ||
|
|
27c539bc8e | ||
|
|
80935a6f6a | ||
|
|
d410a440ba | ||
|
|
2a643d2b1d | ||
|
|
f7b4de6b26 | ||
|
|
01c34330a7 | ||
|
|
756edddbea | ||
|
|
0ca2845ddc | ||
|
|
a912a66602 | ||
|
|
d57191493a | ||
|
|
47ba5baae1 | ||
|
|
5c418feb53 | ||
|
|
0a654f7a64 | ||
|
|
9570c22b4b | ||
|
|
d8636578df | ||
|
|
6f7481a067 | ||
|
|
83b60ccd45 | ||
|
|
f5abc260cb | ||
|
|
cd5067bcd9 | ||
|
|
c083ba276e | ||
|
|
12a30d3dee | ||
|
|
2960c86134 | ||
|
|
2c97fc16cc | ||
|
|
da8e21ecc8 | ||
|
|
e404a881db | ||
|
|
259edc5079 | ||
|
|
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 |
3
.eslintignore
Normal file
3
.eslintignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
dist/
|
||||||
|
lib/
|
||||||
|
node_modules/
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
{
|
{
|
||||||
"env": {
|
"env": { "node": true, "jest": true },
|
||||||
"commonjs": true,
|
"parser": "@typescript-eslint/parser",
|
||||||
"es6": true,
|
"parserOptions": { "ecmaVersion": 9, "sourceType": "module" },
|
||||||
"node": true
|
"extends": [
|
||||||
},
|
"eslint:recommended",
|
||||||
"extends": "eslint:recommended",
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
"globals": {
|
"plugin:@typescript-eslint/recommended",
|
||||||
"Atomics": "readonly",
|
"plugin:import/errors",
|
||||||
"SharedArrayBuffer": "readonly"
|
"plugin:import/warnings",
|
||||||
},
|
"plugin:import/typescript",
|
||||||
"parserOptions": {
|
"plugin:prettier/recommended"
|
||||||
"ecmaVersion": 2018
|
],
|
||||||
},
|
"plugins": ["@typescript-eslint"],
|
||||||
"rules": {
|
"rules": {
|
||||||
}
|
"@typescript-eslint/camelcase": "off"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
1
.github/FUNDING.yml
vendored
Normal file
1
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
github: peter-evans
|
||||||
21
.github/dependabot.yml
vendored
Normal file
21
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "friday"
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
|
||||||
|
- package-ecosystem: "npm"
|
||||||
|
directory: "/"
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
||||||
|
day: "friday"
|
||||||
|
ignore:
|
||||||
|
- dependency-name: "*"
|
||||||
|
update-types: ["version-update:semver-major"]
|
||||||
|
labels:
|
||||||
|
- "dependencies"
|
||||||
|
|
||||||
13
.github/workflows/automerge-dependabot.yml
vendored
Normal file
13
.github/workflows/automerge-dependabot.yml
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
name: Auto-merge Dependabot
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
automerge:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.actor == 'dependabot[bot]'
|
||||||
|
steps:
|
||||||
|
- uses: peter-evans/enable-pull-request-automerge@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
|
pull-request-number: ${{ github.event.pull_request.number }}
|
||||||
|
merge-method: squash
|
||||||
62
.github/workflows/ci.yml
vendored
62
.github/workflows/ci.yml
vendored
@@ -1,65 +1,91 @@
|
|||||||
name: CI
|
name: CI
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [master]
|
branches: [main]
|
||||||
|
paths-ignore:
|
||||||
|
- 'README.md'
|
||||||
|
- 'docs/**'
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [master]
|
branches: [main]
|
||||||
|
paths-ignore:
|
||||||
|
- 'README.md'
|
||||||
|
- 'docs/**'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v1
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: 12.x
|
node-version: 16.x
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
- run: npm run build
|
||||||
|
- run: npm run format-check
|
||||||
|
- run: npm run lint
|
||||||
- run: npm run test
|
- run: npm run test
|
||||||
- run: npm run package
|
- uses: actions/upload-artifact@v3
|
||||||
- uses: actions/upload-artifact@v2
|
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: action.yml
|
||||||
|
path: action.yml
|
||||||
|
|
||||||
test:
|
test:
|
||||||
|
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository
|
||||||
needs: [build]
|
needs: [build]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
target: [built, committed]
|
target: [built, committed]
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
uses: actions/download-artifact@v2
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
|
- if: matrix.target == 'built' || github.event_name == 'pull_request'
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: action.yml
|
||||||
|
path: .
|
||||||
|
|
||||||
- name: Repository Dispatch
|
- name: Test repository dispatch
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
|
||||||
event-type: tests
|
event-type: tests
|
||||||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
||||||
|
|
||||||
|
- name: Test repository dispatch (default payload)
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
event-type: tests
|
||||||
|
|
||||||
package:
|
package:
|
||||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
||||||
needs: [test]
|
needs: [test]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/download-artifact@v2
|
- uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
uses: peter-evans/create-pull-request@v2
|
uses: peter-evans/create-pull-request@v5
|
||||||
with:
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
commit-message: Update distribution
|
commit-message: Update distribution
|
||||||
committer: GitHub <noreply@github.com>
|
|
||||||
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
|
||||||
title: Update distribution
|
title: Update distribution
|
||||||
body: |
|
body: |
|
||||||
- Updates the distribution for changes on `master`
|
- Updates the distribution for changes on `main`
|
||||||
|
|
||||||
Auto-generated by [create-pull-request][1]
|
Auto-generated by [create-pull-request][1]
|
||||||
|
|
||||||
|
|||||||
9
.github/workflows/on-repository-dispatch.yml
vendored
9
.github/workflows/on-repository-dispatch.yml
vendored
@@ -6,7 +6,14 @@ jobs:
|
|||||||
tests:
|
tests:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- name: Dump the client payload context
|
||||||
|
env:
|
||||||
|
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
|
||||||
|
run: echo "$PAYLOAD_CONTEXT"
|
||||||
|
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
if: github.event.client_payload.ref != ''
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.client_payload.ref }}
|
ref: ${{ github.event.client_payload.ref }}
|
||||||
|
|
||||||
- run: echo ${{ github.event.client_payload.sha }}
|
- 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@v3
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
|
||||||
|
config: >
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"command": "rebase",
|
||||||
|
"permission": "admin",
|
||||||
|
"repository": "peter-evans/slash-command-dispatch-processor",
|
||||||
|
"issue_type": "pull-request"
|
||||||
|
}
|
||||||
|
]
|
||||||
17
.github/workflows/test-dispatch.yml
vendored
Normal file
17
.github/workflows/test-dispatch.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
name: Test Dispatch
|
||||||
|
on: workflow_dispatch
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Test repository dispatch
|
||||||
|
uses: peter-evans/repository-dispatch@v2
|
||||||
|
with:
|
||||||
|
# token: ${{ secrets.PUBLIC_REPO_SCOPED_TOKEN }}
|
||||||
|
event-type: tests
|
||||||
|
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
||||||
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"
|
||||||
|
}
|
||||||
73
README.md
73
README.md
@@ -1,24 +1,49 @@
|
|||||||
# Repository Dispatch
|
# Repository Dispatch
|
||||||
|
[](https://github.com/peter-evans/repository-dispatch/actions?query=workflow%3ACI)
|
||||||
[](https://github.com/marketplace/actions/repository-dispatch)
|
[](https://github.com/marketplace/actions/repository-dispatch)
|
||||||
|
|
||||||
A GitHub action to create a repository dispatch event.
|
A GitHub action to create a repository dispatch event.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
Dispatch an event to the current repository.
|
||||||
```yml
|
```yml
|
||||||
- name: Repository Dispatch
|
- name: Repository Dispatch
|
||||||
uses: peter-evans/repository-dispatch@v1
|
uses: peter-evans/repository-dispatch@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
|
||||||
event-type: my-event
|
event-type: my-event
|
||||||
```
|
```
|
||||||
|
|
||||||
## Parameters
|
Dispatch an event to a remote repository using a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token).
|
||||||
|
```yml
|
||||||
|
- name: Repository Dispatch
|
||||||
|
uses: peter-evans/repository-dispatch@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PAT }}
|
||||||
|
repository: username/my-repo
|
||||||
|
event-type: my-event
|
||||||
|
```
|
||||||
|
|
||||||
- `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).
|
### Action inputs
|
||||||
- `repository` - The full name of the repository to send the dispatch. Defaults to the current repository.
|
|
||||||
- `event-type` (**required**) - A custom webhook event name.
|
| Name | Description | Default |
|
||||||
- `client-payload` - JSON payload with extra information about the webhook event that your action or workflow may use. Default: {}
|
| --- | --- | --- |
|
||||||
|
| `token` | `GITHUB_TOKEN` (permissions `contents: write`) or a `repo` scoped [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token). See [token](#token) for further details. | `GITHUB_TOKEN` |
|
||||||
|
| `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://docs.github.com/en/rest/repos/repos#create-a-repository-dispatch-event) events.
|
||||||
|
The default `GITHUB_TOKEN` token can only be used if you are dispatching the same repository that the workflow is executing in.
|
||||||
|
|
||||||
|
To dispatch to a remote repository you must create a [Personal Access Token (PAT)](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the `repo` scope and store it as a secret.
|
||||||
|
If you will be dispatching to a public repository then you can use the more limited `public_repo` scope.
|
||||||
|
|
||||||
|
You can also use a [fine-grained personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) (beta). It needs the following permissions on the target repositories:
|
||||||
|
- `contents: read & write`
|
||||||
|
- `metadata: read only` (automatically selected when selecting the contents permission)
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
@@ -26,16 +51,16 @@ Here is an example setting all of the input parameters.
|
|||||||
|
|
||||||
```yml
|
```yml
|
||||||
- name: Repository Dispatch
|
- name: Repository Dispatch
|
||||||
uses: peter-evans/repository-dispatch@v1
|
uses: peter-evans/repository-dispatch@v2
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.REPO_ACCESS_TOKEN }}
|
token: ${{ secrets.PAT }}
|
||||||
repository: username/my-repo
|
repository: username/my-repo
|
||||||
event-type: my-event
|
event-type: my-event
|
||||||
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
|
||||||
```
|
```
|
||||||
|
|
||||||
Here is an example `on: repository_dispatch` workflow to receive the event.
|
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`).
|
Note that repository dispatch events will only trigger a workflow run if the workflow is committed to the default branch.
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
name: Repository Dispatch
|
name: Repository Dispatch
|
||||||
@@ -46,12 +71,36 @@ jobs:
|
|||||||
myEvent:
|
myEvent:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.event.client_payload.ref }}
|
ref: ${{ github.event.client_payload.ref }}
|
||||||
- run: echo ${{ github.event.client_payload.sha }}
|
- 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@v2
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.PAT }}
|
||||||
|
repository: ${{ matrix.repo }}
|
||||||
|
event-type: my-event
|
||||||
|
```
|
||||||
|
|
||||||
## Client payload
|
## Client payload
|
||||||
|
|
||||||
The GitHub API allows a maximum of 10 top-level properties in the `client-payload` JSON.
|
The GitHub API allows a maximum of 10 top-level properties in the `client-payload` JSON.
|
||||||
@@ -74,6 +123,8 @@ The following payload will succeed.
|
|||||||
client-payload: '{"github": ${{ toJson(github) }}}'
|
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
|
## License
|
||||||
|
|
||||||
[MIT](LICENSE)
|
[MIT](LICENSE)
|
||||||
|
|||||||
13
action.yml
13
action.yml
@@ -2,19 +2,20 @@ name: 'Repository Dispatch'
|
|||||||
description: 'Create a repository dispatch event'
|
description: 'Create a repository dispatch event'
|
||||||
inputs:
|
inputs:
|
||||||
token:
|
token:
|
||||||
description: 'A repo scoped GitHub Personal Access Token'
|
description: 'GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT)'
|
||||||
required: true
|
default: ${{ github.token }}
|
||||||
repository:
|
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:
|
event-type:
|
||||||
description: 'A custom webhook event name.'
|
description: 'A custom webhook event name.'
|
||||||
required: true
|
required: true
|
||||||
client-payload:
|
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:
|
runs:
|
||||||
using: 'node12'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
branding:
|
branding:
|
||||||
icon: 'target'
|
icon: 'target'
|
||||||
color: 'gray-dark'
|
color: 'gray-dark'
|
||||||
|
|
||||||
11710
dist/index.js
vendored
11710
dist/index.js
vendored
File diff suppressed because one or more lines are too long
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
|
||||||
|
}
|
||||||
16550
package-lock.json
generated
16550
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
39
package.json
39
package.json
@@ -1,18 +1,25 @@
|
|||||||
{
|
{
|
||||||
"name": "repository-dispatch",
|
"name": "repository-dispatch",
|
||||||
"version": "1.0.0",
|
"version": "2.0.0",
|
||||||
|
"private": true,
|
||||||
"description": "Create a repository dispatch event",
|
"description": "Create a repository dispatch event",
|
||||||
"main": "src/index.js",
|
"main": "lib/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint src/index.js",
|
"build": "tsc && ncc build",
|
||||||
"package": "ncc build src/index.js -o dist",
|
"format": "prettier --write '**/*.ts'",
|
||||||
"test": "eslint src/index.js && jest --passWithNoTests"
|
"format-check": "prettier --check '**/*.ts'",
|
||||||
|
"lint": "eslint src/**/*.ts",
|
||||||
|
"test": "jest --passWithNoTests"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/peter-evans/repository-dispatch.git"
|
"url": "git+https://github.com/peter-evans/repository-dispatch.git"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [
|
||||||
|
"actions",
|
||||||
|
"repository",
|
||||||
|
"dispatch"
|
||||||
|
],
|
||||||
"author": "Peter Evans",
|
"author": "Peter Evans",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@@ -20,12 +27,22 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/peter-evans/repository-dispatch#readme",
|
"homepage": "https://github.com/peter-evans/repository-dispatch#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "1.2.4",
|
"@actions/core": "^1.10.0",
|
||||||
"@octokit/request": "5.4.2"
|
"@actions/github": "^5.1.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@zeit/ncc": "0.22.1",
|
"@types/jest": "^27.0.3",
|
||||||
"eslint": "6.8.0",
|
"@types/node": "^18.17.12",
|
||||||
"jest": "25.5.4"
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
|
"@vercel/ncc": "^0.36.1",
|
||||||
|
"eslint": "^8.48.0",
|
||||||
|
"eslint-plugin-github": "^4.9.0",
|
||||||
|
"eslint-plugin-jest": "^25.7.0",
|
||||||
|
"jest": "^27.5.1",
|
||||||
|
"jest-circus": "^29.6.4",
|
||||||
|
"js-yaml": "^4.1.0",
|
||||||
|
"prettier": "^2.8.8",
|
||||||
|
"ts-jest": "^27.1.5",
|
||||||
|
"typescript": "^4.9.5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": [
|
|
||||||
"config:base"
|
|
||||||
],
|
|
||||||
"packageRules": [
|
|
||||||
{
|
|
||||||
"depTypeList": ["devDependencies"],
|
|
||||||
"automerge": true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
40
src/index.js
40
src/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();
|
|
||||||
47
src/main.ts
Normal file
47
src/main.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import * as core from '@actions/core'
|
||||||
|
import * as github from '@actions/github'
|
||||||
|
import {inspect} from 'util'
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
function hasErrorStatus(error: any): error is {status: number} {
|
||||||
|
return typeof error.status === 'number'
|
||||||
|
}
|
||||||
|
|
||||||
|
function getErrorMessage(error: unknown) {
|
||||||
|
if (error instanceof Error) return error.message
|
||||||
|
return String(error)
|
||||||
|
}
|
||||||
|
|
||||||
|
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.rest.repos.createDispatchEvent({
|
||||||
|
owner: owner,
|
||||||
|
repo: repo,
|
||||||
|
event_type: inputs.eventType,
|
||||||
|
client_payload: JSON.parse(inputs.clientPayload)
|
||||||
|
})
|
||||||
|
} catch (error) {
|
||||||
|
core.debug(inspect(error))
|
||||||
|
if (hasErrorStatus(error) && error.status == 404) {
|
||||||
|
core.setFailed(
|
||||||
|
'Repository not found, OR token has insufficient permissions.'
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
core.setFailed(getErrorMessage(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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