skip to Main Content

I can trigger a workflow based on a push to my repo with

on:
  push

Is it possible to trigger a workflow when there is a push to another public repo that I don’t have push access to, such as phpmyadmin?

3

Answers


  1. I’m pretty sure the answer is no, you can’t programmatically subscribe one repo to another repo’s events.

    However what you could do is run a scheduled job (once per day, or more frequently if you need) to check for any updates. You could store the last known SHA in your repo, then update it via a PR or direct commit when the action detects an update.

    This is similar to what tools like https://dependabot.com/ do.

    Login or Signup to reply.
  2. You can use “Repository_dispatch” trigger to trigger any workflow. The link below can be helpful to use

     on:
            repository_dispatch:
                types: [start-example-workflow]
    

    With that payload, you can POST the request to https://api.github.com/repos/:owner/:repo/dispatches to trigger workflows

    Accept:  application/vnd.github.everest-preview+json
    Content-Type: application/json
    Authorization: Bearer {{personal_access_token}}
    
    {
        "event_type": "my_event_type",
        "client_payload": {
            "example-key": "example-value"
        }
    }
    

    Let me know if this helps you out.

    Login or Signup to reply.
  3. This may be not helpful if you don’t have access to both repositories, but since I haven’t found any other solution I post it anyway.

    The solution can happen on push or any other event and it’s using this dispatch github action:

    name: Trigger PR in PMS on release
    on: push
    
    jobs:
      build:
        name: Dispatch an update
        steps:
          - uses: mvasigh/dispatch-action@main
            with:
              token: ${{ secrets.GH_TOKEN }}
              repo: from-repository
              event_type: update_event
    

    then listen to the event_type from the subscribed repository:

    name: Update event
    on:
      repository_dispatch:
        types: [update_event]
    
    jobs:
      build:
        steps:
          - run: yarn
          ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search