Skip to content

Commit

Permalink
Merge peter-evans/repository-dispatch (#2)
Browse files Browse the repository at this point in the history
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Peter Evans <[email protected]>
Co-authored-by: Thijs van Tol <[email protected]>
Co-authored-by: actions-bot <[email protected]>
Co-authored-by: actions-bot <[email protected]>
  • Loading branch information
6 people authored Jul 9, 2024
1 parent 3dc273a commit c6d9ede
Show file tree
Hide file tree
Showing 11 changed files with 2,025 additions and 998 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.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@v3
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: action.yml
path: action.yml
Expand All @@ -45,14 +45,14 @@ jobs:
matrix:
target: [built, committed]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
path: dist
- if: matrix.target == 'built' || github.event_name == 'pull_request'
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: action.yml
path: .
Expand All @@ -73,13 +73,13 @@ jobs:
needs: [test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: dist
path: dist
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
commit-message: Update distribution
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/on-repository-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
PAYLOAD_CONTEXT: ${{ toJson(github.event.client_payload) }}
run: echo "$PAYLOAD_CONTEXT"

- uses: actions/checkout@v3
- uses: actions/checkout@v4
if: github.event.client_payload.ref != ''
with:
ref: ${{ github.event.client_payload.ref }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/slash-command-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v3
uses: peter-evans/slash-command-dispatch@v4
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
config: >
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/test-dispatch.yml
Original file line number Diff line number Diff line change
@@ -1,13 +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
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PUBLIC_REPO_SCOPED_TOKEN }}
# token: ${{ secrets.PUBLIC_REPO_SCOPED_TOKEN }}
event-type: tests
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
31 changes: 31 additions & 0 deletions .github/workflows/update-major-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update Major Version
run-name: Update ${{ github.event.inputs.main_version }} to ${{ github.event.inputs.target }}

on:
workflow_dispatch:
inputs:
target:
description: The target tag or reference
required: true
main_version:
type: choice
description: The major version tag to update
options:
- v3

jobs:
tag:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
fetch-depth: 0
- name: Git config
run: |
git config user.name actions-bot
git config user.email [email protected]
- name: Tag new target
run: git tag -f ${{ github.event.inputs.main_version }} ${{ github.event.inputs.target }}
- name: Push new tag
run: git push origin ${{ github.event.inputs.main_version }} --force
34 changes: 30 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ A GitHub action to create a repository dispatch event.
Dispatch an event to the current repository.
```yml
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
event-type: my-event
```
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
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: username/my-repo
Expand Down Expand Up @@ -51,7 +51,7 @@ Here is an example setting all of the input parameters.

```yml
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: username/my-repo
Expand Down Expand Up @@ -94,7 +94,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: ${{ matrix.repo }}
Expand Down Expand Up @@ -125,6 +125,32 @@ 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.

### Multiline

A multiline `client-payload` can be set directly in YAML, as in the following example.

```yml
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PAT }}
repository: username/my-repo
event-type: my-event
client-payload: |-
{
"repo": {
"name": "${{ github.repository }}",
"branch": "${{ needs.build_cfg.outputs.REPO_BRANCH }}",
"tag": "${{ needs.build_cfg.outputs.REPO_TAG }}"
},
"deployment": {
"project": "${{ env.MY_PROJECT }}",
"container": "${{ env.MY_CONTAINER }}",
"deploy_msg": "${{ env.SLACK_DEPLOY_MSG }}",
}
}
```

## License

[MIT](LICENSE)
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
description: 'JSON payload with extra information about the webhook event that your action or worklow may use.'
default: '{}'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
branding:
icon: 'target'
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const github = __importStar(__nccwpck_require__(5438));
const util_1 = __nccwpck_require__(3837);
/* eslint-disable @typescript-eslint/no-explicit-any */
function hasErrorStatus(error) {
return typeof error.code === 'number';
return typeof error.status === 'number';
}
function getErrorMessage(error) {
if (error instanceof Error)
Expand Down Expand Up @@ -643,7 +643,7 @@ class OidcClient {
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
Expand Down
Loading

0 comments on commit c6d9ede

Please sign in to comment.