GithubHelp home page GithubHelp logo

peter-evans / repository-dispatch Goto Github PK

View Code? Open in Web Editor NEW
882.0 11.0 125.0 3.05 MB

A GitHub action to create a repository dispatch event

License: MIT License

JavaScript 15.57% TypeScript 84.43%
repository-dispatch github-action github-api webhook-events

repository-dispatch's Introduction

Repository Dispatch

CI GitHub Marketplace

A GitHub action to create a repository dispatch event.

Usage

Dispatch an event to the current repository.

      - name: Repository Dispatch
        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).

      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.PAT }}
          repository: username/my-repo
          event-type: my-event

Action inputs

Name Description Default
token GITHUB_TOKEN (permissions contents: write) or a repo scoped Personal Access Token (PAT). See 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 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) 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 (beta). It needs the following permissions on the target repositories:

  • contents: read & write
  • metadata: read only (automatically selected when selecting the contents permission)

Example

Here is an example setting all of the input parameters.

      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.PAT }}
          repository: username/my-repo
          event-type: my-event
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

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.

name: Repository Dispatch
on:
  repository_dispatch:
    types: [my-event]
jobs:
  myEvent:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        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. In the following example, after the build job succeeds, an event is dispatched to three different repositories.

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@v3
        with:
          token: ${{ secrets.PAT }}
          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.

client-payload: ${{ toJson(github) }}

To solve this you can simply wrap the payload in a single top-level property. The following payload will succeed.

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.

      - 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

repository-dispatch's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

repository-dispatch's Issues

Include a link to the dispatched workflow

It would be awesome if after dispatching a workflow, this action could log the URL to the active workflow of the receiver. Maybe this just required querying Github for the run number once the run has been scheduled?

example property names don't align

in the example, client-payload is kebab-case

with:
  client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

but in the receiving repository's workflow, this property is referenced in snake_case:

  with:
    ref: ${{ github.event.client_payload.ref }}
- run: echo ${{ github.event.client_payload.sha }}

I can see in the source what's happening - you've decided expect an input of client-payload but GitHub's API requires it be client_payload when sending this data through its API.

If this were to change it would be a breaking change and users would need to upgrade to a next major version of the action.

##[error]Not Found on every run

Error I get. What am I missing? Really want this to work.

with:
token: ***
event-type: my-event
client-payload: {"ref": "refs/heads/master", "sha": "f71d129c3362c56acf734863f873aa8bb3281459"}
repository: ******
##[error]Not Found

name: Alert parent repository on push
on:
push:
branches:
- **********

jobs:
dispatch:
name: Dispatch to other-repo
runs-on: ubuntu-latest
steps:
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@master
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
#repository: test-dispatch
event-type: my-event
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

Another job waitingto this event does exist and everything.

Question: can I use it for organization projects?

Hi, I was wondering if this action can be used from an organization repository. According to documentation, the repository attribute should be something like: username/my-repo. I tried with an organization (organization/repo-b, using a personal token) and the event is never caught by the repo-b. I have used branches for testing purposes.
Any suggestion?

[error] Resource not accessible by integration

    - name: Repository Dispatch
      uses: peter-evans/[email protected]
      with:
        # A repo scoped GitHub Personal Access Token
        token: ${{ secrets.GITHUB_TOKEN }}
        # The full name of the repository to send the dispatch.
        repository: MrThanlon/meclass
        # A custom webhook event name.
        event-type: updated

Support WorkflowID when Triggering another Repository

I found your workflow to trigger another (or same in my case) repository. The essential part about this idea, which is way easier implemented in GitLab) is to trigger upstream pipelines. This needs a way to trigger another workflow.

By looking at https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#create-a-workflow-dispatch-event, a workflow_id is supported in REST API. Can you please add a workflow parameter to your action?

image

Dispatch same event to several repos

Is this possible without duplicating the step several times? Something like

- name: Repository Dispatch
  uses: peter-evans/repository-dispatch@v1
  with:
    token: ${{ secrets.REPO_ACCESS_TOKEN }}
    repository: [slug1/repo1, slug2/repo2, ...]
    event-type: my-event

workflow triggered by wrong actor

I love this action, it made starting workflows from other repositories super easy. We are using this action in a submodule repository to trigger workflows on all repositories which use the submodule whenever master is updated.

The problem we are finding is that workflow runs triggered by repository-dispatch are reporting "Repository dispatch triggered by TJKrawczynski2" in the actions tab always, even when the original repository-dispatch action was triggered by someone else in the submodule. Essentially this means TJKrawczynski2 (me) is the only one who gets notified of failed CI runs instead of the developers who originally made changes on the submodule.

I suspect the "actor" field is not getting forwarded to the repository_dispatch-triggered workflow properly, I tried looking over your code but got a little lost since I've never worked with typescript or any java-related languages really... Any help will be appreciated!

Question: Github Token

This is a question

Thanks for the GitHub Action, I want to ask if I can use ${{ secrets.GITHUB_TOKEN }} with this action?

Thanks.

Repository not found, OR token has insufficient permissions.

What I've got:

  • Private organization where private repo A is attempting to trigger a dispatch to another private rebo B, in the same org
  • PAC being used is for a user that has Admin across the whole private org
  • PAC being used has god rights (everything is checked)

The workflow step:

      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REDACTED_SECRET_NAME }}
          repository: redacted-org/redacted-repo
          event-type: redacted-event-name
          client-payload: '{"repo": "${{ github.repository }}", "release_id": "${{ steps.create_release.outputs.id }}", "chart_name": "${{ env.HELM_CHART_NAME }}"}'

The repository is defined as org-name/repo-name, and is spelled correctly.

The error:

Error: Repository not found, OR token has insufficient permissions.

At this point, there is no higher permissions to give on either the user (which is part of the private org), or the PAC used in the workflow. Not sure what else to check. Thoughts?

If repository dispatch is not found

I have a main workflow which triggers multiple repos having repository dispatch. Is it possible to put a condition to check if repository dispatch is not present in any of the downstream repos then that repository execution can be skipped by main workflow? If not, then how to handle conditional scenarios with repository dispatch?

Workflows not triggering when there are multiple repositories

Hi, I'm trying to use an repository which receives the same event from different repositories. What I don't understand it's why it works with a repository (A) and it doesn't work if I've the same configuration in a repository (B).

This is my subtree repository on listen-dispatch.yml

# listen-dispatch.yml file 
name: listen trigger events from another repository

on:
  repository_dispatch:
    types: [update-subtree-repository]

jobs:
  build:
    name: run-workflow
    runs-on: self-hosted
    steps:
      - name: Checkout project
        uses: actions/checkout@v3
        with:
          ref: master
          fetch-depth: 0
      - name: Create environment variables
        run: |
          echo "REPOSITORY_NAME=`basename ${{ github.event.client_payload.repository }}`" >> $GITHUB_ENV
          echo "[email protected]:${{ github.event.client_payload.repository }}.git" >> $GITHUB_ENV
      - name: Get changes
        run: make git-subtree-pull REPOSITORY_NAME=${{ env.REPOSITORY_NAME}} REPOSITORY_URL=${{ env.REPOSITORY_URL }}
      - name: update changes
        run: make upload-changes-to-remote

This is what I've on my repositories which send the event to the previous one, there's one of them which works though there is another one which has the same configuration and share the access token from the same organization, both are private repositories.

# repository-dispatch.yml file on multiple repositories from the same organization which share the same PAT
name: trigger events in another repository

on:
  push:
    branches: [ master ]

jobs:
  testing-trigger:
    runs-on: self-hosted
    steps:
      - name: Repository Dispatch
        uses: peter-evans/[email protected]
        with:
          token: ${{ secrets.ACCESS_TOKEN }}
          repository: myorg/mysubtree-repo
          event-type: update-subtree-repository
          client-payload: '{ "repository": "${{ github.repository }}" }' # optional, default is {}

Trigger workflow from outside of another repository

Is there an event to listen for when something is pushed to an outside repository within my organization?

I am trying to build a workflow that pushes a tag to a repository anytime a new repository is created and pushed to. I don't know when the repository will be created or who will create it. And I need to execute the workflow I have from outside of the repository I want to add the tag to. Is this possible?

name: Check Github Tags

on: push

jobs: 
  check-git-tags:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Print Repository info
        run: |
          echo 'Commit:' $GITHUB_SHA
          echo 'Repository:' $GITHUB_REPOSITORY
          echo 'Workspace:' $GITHUB_WORKSPACE
          echo 'Ref:' $GITHUB_REF
          git tag
      - name: Push new tag
        id: push_new_tag
        uses: anothrNick/[email protected]
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          CUSTOM_TAG: test2
      - name: Print New Tag Added
        run: echo 'New tag' ${{steps.push_new_tag.outputs.new_tag}} 'added to commit' $GITHUB_SHA 'in' $GITHUB_REPOSITORY.

Bump minimatch version

Hi Peter,

I want to use this github action in my work, but the security team says [email protected] has a high vulnerability. Is it possible to bump this package's version? Thanks!

Hot To Get Json From Sender to Receiver

i am using this code from a.yml (sender)

  - name: Repository Dispatch
    uses: peter-evans/repository-dispatch@v2
    if: always()
    with:
      token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
      repository: abc/cde
      event-type: cd_development_event
      client-payload: >-
        {
            "sha": "${{ github.sha }}",
            "ref": "${{ github.ref }}",
            "configuration": "${{ github.event.inputs.configuration }}",
            "deployment": "${{ github.event.inputs.deployment }}",
            "note": "${{ github.event.inputs.note }}",
            "webhook": "${{ secrets.WEBHOOK_TEAMS_DEVELOPMENT }}",
            "needs": ${{ toJson(needs) }},
            "job": ${{ toJson(job) }},
            "steps": ${{ toJson(steps) }}
        }

and for receiver in b.yml, iam using like this
- name: Send a Report
uses: skitionek/notify-microsoft-teams@master
with:
needs: ${{ github.event.client_payload.needs }}
job: ${{ github.event.client_payload.job }}
steps: ${{ github.event.client_payload.steps }}

and when send a report is run, i got an error. this is my error :
Error: .github/workflows/cn_teams.yml (Line: 47, Col: 18): A mapping was not expected
Error: .github/workflows/cn_teams.yml (Line: 48, Col: 16): A mapping was not expected
Error: .github/workflows/cn_teams.yml (Line: 49, Col: 18): A mapping was not expected
Error: The template is not valid. .github/workflows/cn_teams.yml (Line: 47, Col: 18): A mapping was not expected,.github/workflows/cn_teams.yml (Line: 48, Col: 16): A mapping was not expected,.github/workflows/cn_teams.yml (Line: 49, Col: 18): A mapping was not expected

and when i am display value from reciver, this my error
# - name: needs
# run: echo ${{ github.event.client_payload.needs }}

output : {}

  # - name: job  
  #   run: echo ${{ github.event.client_payload.job }}

output : {}

expected output :
{
"needs": {},
"job": {
"status": "success"
},
"steps": {}
}

please, how to get that json from sender to receiver. thank you

check the status of "Repository Dispatch" workflow?

How to check in my next step to "Repository Dispatch" workflow status ?

  • name: Repository Dispatch
    uses: peter-evans/repository-dispatch@v1
    with:
    token: *****
    repository: username/anotherrepo
    event-type: my-event
    client-payload: '{"sample": "${{ env.sample}}"}'

  • name: ....

Custom branch support for "repository_dispatch"

Hi,
I'm trying to trigger a github actions workflow in a non-default branch. Is there any way I can do that using your Action?
I want to run workflow on custom branch.

I tried dispatch using just appending "/custom_branch_name",
like "sunn-e/myRepo/dev" , it showed green tick but did not actually trigger, s in it was not received.

Pull request link doesn't match when triggering repository dispatch

Hi @peter-evans, currently i have a workflow that triggers repository dispatch from issue comments. This has been an issue since the the repository dispatch workflow doesn't displayed the current PR when triggering from issue comments job. Is there any chance to hardcode the PR to be displayed for repository dispatch? Thank You!

Repository Dispatch :
Screen Shot 2022-05-13 at 10 56 03

Issue Comments :
Screen Shot 2022-05-13 at 10 58 09

Checking on endpoint's response to set success or failed status

First I apologized if this isn't the right place to ask since I don't know where to find official Github API's channel or repo to ask.
I went through the developer and newer API docs as well as your source code, I'd think there'd be a response either 204 or 4xx code that can be returned to the action's to determine if the POST request actually delivered & acknowledged, but I didn't find it when I read the job run log. It seems like a missed opportunity to be able to flag the step as successful with better confidence.

Can it be implemented?

Unexpected token ' in JSON at position 0 | Multiline client_payload

So I am trying to implement a multiline client_payload, my configuration:

  call-gke-cd:
    if: >
      ${{
      (startsWith(github.event.head_commit.message, '[PROD]:')) || 
      (github.ref != 'refs/heads/master')
      }}
    name: CD / Deploy to Kubernetes
    runs-on: ubuntu-22.04
    needs: [affected-services, build-and-push-docker]
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v2
        with:
          token: ${{ secrets.GIT_ACCESS_TOKEN }}
          repository: myorg/myrepo
          event-type: deploy
          client-payload: >
            '{"ref": "${{ github.ref }}", 
            "image_tag": "${{ needs.affected-services.outputs.project_version }}", 
            "services": "${{ needs.affected-services.outputs.matrix }}"}'

I get fails of Unexpected token ' in JSON at position 0

is readme example correct?

According to the documentation the repository_dispatch event doesn't use the types property.

This event does not have additional activity types so it does not support the types keyword.

Should the example be:

name: Repository Dispatch
on: repository_dispatch

jobs:
  myEvent:
    if: github.event.action == 'my-event'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.client_payload.ref }}
      - run: echo ${{ github.event.client_payload.sha }}

or does it work with the types property?

Error: Parameter token or opts.auth is required

The workflow does not run. I am admin of the public repository.

PRUpdates.yml - Workflow that sends the dispatch.

name: PR Updates

on:
  pull_request:
    types: [opened, reopened]

jobs:
  dispatch:
    runs-on: ubuntu-latest
    name: Trigger Telegram notifier workflow
    steps:
      - name: Repository Dispatch
        uses: peter-evans/[email protected]
        with:
          token: ${{ secrets.PAT }}
          event-type: pr-opened
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}", "title": "${{ github.event.pull_request.title }}", "creator": "${{ github.actor }}"}'

notifier.yml - Workflow triggered on dispatch


name: GitHub Notifier

on:
  repository_dispatch:
    types: [pr-opened]

jobs:
  build:
    name: Telegram Notify
    runs-on: ubuntu-latest
    steps:
      - name: Notify telegram group on pull request changes
        uses: appleboy/[email protected]
        with:
          to: ${{ secrets.TELEGRAM_TO }} # don't change
          token: ${{ secrets.TELEGRAM_TOKEN }} # don't change
          ref: ${{ github.event.client_payload.ref }}
          message: |
            **${{ github.event.client_payload.title }}**
            @${{ github.event.client_payload.creator }} opened a pull request.

Screenshot 2022-10-04 at 10 37 13 AM

Screenshot 2022-10-04 at 11 02 17 AM

Token
Screenshot 2022-10-04 at 10 54 03 AM

Incorrect Usage in README.md

The usage specify:

      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1

But the version v1 doesn't exists. It should be v1.0.0 or v1.1.1 to use the current latest version.

Can't seem to use `public_repo`

The documentation says

you can use the more limited public_repo scope.

which doesn't seem to be true (from both reading GH docs and trying it out)

Did you get it to work that way? Maybe it depends on a setting.

Using yaml as client-payload

Would it be possible, rather than specifying the client-payload as a json string, to juist build a yaml object and have that be converted into json?

- name: Repository Dispatch
  uses: peter-evans/repository-dispatch@v2
  with:
    token: ${{ secrets.PAT }}
    repository: username/my-repo
    event-type: my-event
    client-payload:
      ref: ${{ github.ref }}
      sha: ${{ github.sha }}
      

Is it possible to get the run_id that's triggered by repository-dispatch?

Hi, I have a request like below:

  1. trigger the do-something by repository-dispatch
  2. need the do-something run id
  3. check the do-something status.
  4. repeat above again and again

below is my yaml

  Benchmarks_Test:
    name: Build Modified
    runs-on: [ self-hosted, Linux, X64, package-for-linux ]
    strategy:
      matrix:
        repeat: [1, 2]
    continue-on-error: true
    concurrency:
      group: Benchmarks_Test_${{matrix.repeat}}
      cancel-in-progress: true
    steps:
      - uses: actions/checkout@v2
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.WORKFLOW_TOKEN }}
          event-type: do-something
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
      - name: check each  do-something status by run id

It is not triggering the workflow in other repo

Both workflows are in default branch on each repos still not dispatching an event.

Dispatcher

name: Codegen
on:
  push:
    branches:
      - develop
jobs:
  dispatch:
    runs-on: ubuntu-latest
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          repository: org-name/repo-name
          event-type: my-event

Reciever


name: Graphql Codegen
on:
  repository_dispatch:
    types: [my-event]
jobs:
  codegen:
    runs-on: ubuntu-latest
    steps:

But when I tried to dispatch via curl, it triggers the workflow on the receiver repo.


   curl \
    -X POST \
    -H "Accept: application/vnd.github.v3+json" \
    -H "Authorization: token ghp_token_with_repo_workflow_scope" \
    https://api.github.com/repos/org-name/repo-name/dispatches \
    -d '{"event_type":"my-event","client_payload":{"command":"ping"}'

My personal access token has repo + worfklow scope

Workflows not triggering

Hello,
I have bunch of workflows that i'd like to manage with this action.
Problem is workflows that are supposed to get triggered are not triggerin.
I have followed instructions at https://stevenmortimer.com/running-github-actions-sequentially/ .
At the moment my workflows are defined only in one branch. Is that a problem for this action?

I'm doing something like this as per instructions as a last part of my first workflow:

  - name: Trigger next workflow
    if: success()
    uses: peter-evans/repository-dispatch@v1
    with:
      token: ${{ secrets.REPO_GHA_PAT }}
      repository: ${{ github.repository }}
      event-type: trigger-test-workflow
      client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

And this is the next workflow start:

name: Next test workflow
on:
  repository_dispatch:
    types: [trigger-test-worflow]

Edit. Just read that it only triggers if it's in main branch. I guess this just turned into feature request if it's possible to implement.

Specify what branch to trigger on remote repo

I have this job below on workflow one which will supposedly trigger another workflow which resides on the master branch on another repo.

This workflow is being triggered everytime a push event is captured on 'develop' branch

name: Repository Dispatch
      uses: peter-evans/repository-dispatch@v1
      with:
        token: ${{ secrets.REPO_ACCESS_TOKEN }}
        repository: same-user/another-repo
        event-type: trigger-deployment
        client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

It's triggering just fine but it's failing to run because workflow2 is looking for develop branch on my other repo which is not existent.

Is there a way to tell what branch is going to be triggered?

Error: Resource not accessible by integration

Hi, thank you for this repo! I'm trying to apply repository_dispatch in the same repo and pass metadata from one workflow to another. My code is shown below and it's throwing an error Error: Resource not accessible by integration. Why is it throwing that error? I thought for local dispatch it doesn't need secrets.GITHUB_TOKEN or PAT?

  save-to-dispatch:
    runs-on: ubuntu-latest
    needs: [set-tag, build-image-and-push]
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v2
        with:
          event-type: version-tag
          client-payload: '{"dispatch_origin": "production", "tag": "${{ needs.set-tag.outputs.tag }}"}'

fine-grained personal access tokens

PATs seem to be more complicated now, I couldn't just choose "public_repo" permissions, I had to choose whether to not allow, allow read-only or allow read/write for like 30 different things.

https://github.com/settings/personal-access-tokens/new

I chose 6 that looked good, and it seems to have worked but I forget which ones I chose and I don't think I can see. It would be great if the documentation listed the permissions that need to be set.

Not triggering workflow

Both of my workflows are on master of my repository. I'm not getting any error messages, however the workflow is not being triggered

Workflow that should be the trigger

  verification:
    name: Workflow - Lint, Test & Build
    runs-on: 'ubuntu-latest'

    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{ github.token }}
          repository: ${{ github.repository }}
          event-type: run-lint-test-build
          client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'

Workflow that I am attempting to trigger

name: Lint, Test & Build

on:
  repository_dispatch:
    types: [run-lint-test-build]

jobs:
  verification:
    name: Lint, Test & Build
    runs-on: ubuntu-latest

    steps:
      - name: Checkout source code
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.client_payload.ref }}
      - run: echo ${{ github.event.client_payload.sha }}

Workflow runs regardless of event-type

I have a test repo-dispatch action in my first repo:


name: Test 
on: 
  push:
    paths:
    - '.github/workflows/test-repo-dispatch.yml'
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Repository Dispatch
        uses: peter-evans/repository-dispatch@v1
        with:
          token: ${{secrets.SECRET}}
          repository: polyverse/polyscripted-wordpress
          event-type: x

In my downstream repo it is supposed to run on a specific type of dispatch, yet is triggered regardless of what event type is added.

  repository_dispatch:    
    type: [build_7.2_apache]

The above workflow runs even with event type "x" sent.

Repository-dispatch to list of repositories

Hi,
I love using your action script. However, I was wondering whether it is possible to repository-dispatch a whole of repos as targets?

Thanks again for developing this awesome tool!

404 Error on hitting github dispatches API

occasionally can't hit the github dispatches API, here's the error logs :

Run 689b4c9
with:
token: ***
repository: tokopedia/ansible-v2
event-type: apply
client-payload: { "pr_number": "20897", "extra_vars": "", "tags": "", "limit": "", "comment_body": "ghtoped apply", "pr_url": "https://api.github.com/repos/tokopedia/ansible-v2/pulls/20897"}
env:
GCS_FILE: true
COMMENT_BODY: ghtoped apply
Error: request to https://api.github.com/repos/tokopedia/ansible-v2/dispatches failed, reason: getaddrinfo ENOTFOUND api.github.com

Feature request: specify client payload as path to json file

Specifying the client-payload value can be problematic. As this is created within a workflow file, I can't benefit from any syntax validation or syntax highlighting that might otherwise help in spotting a mistake.

If I were instead able to store the required payload in a file, I could:

  • use my IDE's syntax highlighting to make me aware of the mistakes my fallible human brain makes
  • lint json payload files in pull requests and fail builds if invalid json is encountered
  • make my workflow yaml easier to hand edit by not having to mentally switch between yaml and json modes in my head

Ideally a workflow step may then end up looking like:

- name: Dispatch event
  uses: peter-evans/repository-dispatch@v1
  with:
    repository: example/repo
    event-type: event-type-name
    client-payload-file: ./path/to/payload.json

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.