Reputation: 50386
In my company we have a few hundred repositories, for at least 20 of those we want to apply linting by doing github actions.
It seems not good to copy the same github action workflow into each .github/workflows
folder for a few reasons one is that the action is duplicated, no single source of truth, there should be one file somewhere if we change it then all the other files change.
How to apply one github action to multiple github repositories without copying this file into every single .github/workflows
folder in every one of these github projects?
This is a github enterprise account.
Upvotes: 3
Views: 3231
Reputation: 1324228
Q1 2024: the old "organization-wide required workflow" (see below second section) have been replaced with rulesets. (I mentioned those before here or there)
A ruleset is a named list of rules that applies to a repository, or to multiple repositories in an organization.
You can create rulesets to control how people can interact with selected branches and tags in a repository.
You can control things like who can push commits to a certain branch and how the commits must be formatted, or who can delete or rename a tag.For example, you could set up a ruleset for your repository's feature branch that requires signed commits and blocks force pushes for all users except repository administrators.
See for instance "Require workflows to pass before merging"
Ruleset workflows can be configured at the organization level to require workflows to pass before merging pull requests.
More on "Creating rulesets for repositories in your organization"
Original answer: Check if this new feature (Jan. 2023) can help:
GitHub Actions – Support for organization-wide required workflows public beta (Jan. 2023)
Today, we are announcing public beta of required workflows in GitHub Actions
Required workflows allow DevOps teams to define and enforce standard CI/CD practices across many source code repositories within an organization without needing to configure each repository individually.
Organization admins can configure required workflows to run on all or selected repositories within the organization.Required workflows will be triggered as required status checks for all the pull requests opened on the default branch, which blocks the ability to merge the pull request until the required workflow succeeds.
Individual development teams at the repository level will be able to see what required workflows have been applied to their repository.
https://i0.wp.com/user-images.githubusercontent.com/25578249/211552010-d7aa7c25-f204-4c20-a04b-9c53f74ec52e.png?ssl=1 -- Required workflows run at repo
In addition to reducing duplication of CI/CD configuration code, required workflows can also help companies with the following use cases:
Security: Invoke external vulnerability scoring or dynamic analysis tools.
Compliance: Ensure that all code meets an enterprise’s quality standards.
Deployment: Ensure that code is continuously deployed in a standard way.
Upvotes: 1