Webhook to trigger Github Actions #138466
Replies: 2 comments 1 reply
-
It sounds like you're aiming for centralized GitHub Actions logic that can be triggered by pushes across multiple repositories, while minimizing maintenance efforts. There are a few approaches that could streamline this process: 1. GitHub API + Centralized ActionYou could use the GitHub REST or GraphQL API to have your central repository listen for webhook events from other repositories. While GitHub Actions cannot directly listen to events from other repositories, this can be managed through the GitHub API. Here's a potential workflow:
2. GitHub Actions in Repositories + Centralized LogicInstead of a fully custom solution, each repository could have a lightweight GitHub Action to trigger the central repository’s logic. You could add a minimal action file to each repository like this: name: Trigger Central Workflow
on: [push]
jobs:
trigger-central-workflow:
runs-on: ubuntu-latest
steps:
- name: Send repository dispatch
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/org-name/central-repo/dispatches \
-d '{"event_type": "repo-trigger", "client_payload": { "repository": "${{ github.repository }}" }}' This reduces the complexity in each repository while offloading most of the logic to the central repo. You wouldn't have to manage complex workflows across multiple repositories. 3. GitHub Apps ApproachSince you’ve already explored GitHub Apps, consider using the GitHub Apps framework to directly trigger actions on your central repository via 4. Monorepo StructureIf it's feasible for your organization, another approach could be to consolidate these repositories into a monorepo. This way, you'd only need one set of actions for all the projects and a single push would naturally trigger everything. 5. GitHub Organization-Level ActionAlthough GitHub doesn't directly support organization-level actions that can trigger across multiple repositories without setup, you can create a shared workflow that’s reusable. This can be stored in a central location and referenced by all repositories, ensuring you don’t need to maintain separate logic for each one: In your central repository: # .github/workflows/shared-workflow.yml
name: Shared Workflow
on:
repository_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- run: echo "This is a shared workflow" In other repositories, reference it like this: name: Trigger Central
on: [push]
jobs:
call-shared-workflow:
uses: org-name/central-repo/.github/workflows/shared-workflow.yml@main These solutions centralize logic while reducing the need to maintain extensive actions across all repositories. If avoiding infrastructure setup is critical, using the GitHub API with |
Beta Was this translation helpful? Give feedback.
-
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
-
Select Topic Area
Question
Body
Hi !
I have multiple repositories in my organization and I want to have single point of rules and logic of how pushes from these repositories are handled. I also need in occassion that central logic system to run multiple pushes together and allow them to work with a single validation process that includes multiple changes.
So the idea is to have a repo for central github actions that will hold a big part of the logic.
Our current difficulty is how to get pushes from these multiple repositories to trigger my github actions logic in my central repository.
Appriciate any input here, maybe we have overseen a solution that Github provides that can support us.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions