|
| 1 | +# Create Separate Repo for Custom GitHub Actions |
| 2 | + |
| 3 | +## Idea Overview |
| 4 | + |
| 5 | +Create a separate repository within the `instructlab` GitHub org to house our custom CI Github Actions. |
| 6 | + |
| 7 | +## Motivation for this Proposal |
| 8 | + |
| 9 | +Within our `instructlab` GitHub org, we have an in-house GitHub action that we use across several repos: `free-disk-space`. |
| 10 | + |
| 11 | +Examples: |
| 12 | + |
| 13 | +- [`free-disk-space` in the `eval` repo](https://github.com/instructlab/eval/blob/main/.github/actions/free-disk-space/action.yml) |
| 14 | +- [`free-disk-space` in the `instructlab` repo](https://github.com/instructlab/instructlab/blob/main/.github/actions/free-disk-space/action.yml) |
| 15 | +- [`free-disk-space` in the `sdg` repo](https://github.com/instructlab/sdg/blob/a532a8d99ffe447152948e9442464923aba62637/.github/actions/free-disk-space/action.yml) |
| 16 | + |
| 17 | +This GitHub action is universal as it is a simple script used to clean up disk space on GitHub runners and can be modified to free disk space on our CentOS-based EC2 runners. |
| 18 | + |
| 19 | +Note that all of these in-house `free-disk-space` action files are exactly the same, so we essentially have the same file stored in three different repos. |
| 20 | + |
| 21 | +## Pros and Cons |
| 22 | + |
| 23 | +Below are some pros and cons of creating a separate repository to house our GitHub actions. |
| 24 | + |
| 25 | +### Pros |
| 26 | + |
| 27 | +- We will have one action file in one location |
| 28 | + - Easier to make changes in one location instead of (our present) three locations |
| 29 | + - Contributors will know where to look for in-house action files |
| 30 | +- We can create releases and utilize version control |
| 31 | + |
| 32 | +### Cons |
| 33 | + |
| 34 | +- Extra repository to maintain. |
| 35 | +- We can't publish any of our actions to the GitHub marketplace if we have multiple actions stored in one repository.\* |
| 36 | + |
| 37 | +\* In reference to the last bullet point, [the GitHub docs for publishing Actions](https://docs.github.com/en/actions/sharing-automations/creating-actions/publishing-actions-in-github-marketplace#about-publishing-actions) states: |
| 38 | +> Actions are published to GitHub Marketplace immediately and aren't reviewed by GitHub as long as they meet these requirements: |
| 39 | +> |
| 40 | +> - The action must be in a public repository. |
| 41 | +> - Each repository must contain a single action. |
| 42 | +
|
| 43 | +If we do care about publishing our actions, then we should consider creating separate repositories for these actions. If we don't care to publish, then this is a non-issue. (See next section below.) |
| 44 | + |
| 45 | +## Additional Info |
| 46 | + |
| 47 | +Even if we cannot publish our actions to the GitHub marketplace, we can _still_ use these actions in our repository. For example, if our repo was named `ci-actions` with this layout: |
| 48 | + |
| 49 | +```bash |
| 50 | +. |
| 51 | +├── custom-action-1/ |
| 52 | +│ ├── action.yml |
| 53 | +├── custom-action-2 |
| 54 | +│ ├── action.yml |
| 55 | +``` |
| 56 | + |
| 57 | +...then we'd reference them in our other repos like so: |
| 58 | + |
| 59 | +```yaml |
| 60 | +name: Some Name |
| 61 | + |
| 62 | +on: |
| 63 | + workflow_dispatch: |
| 64 | + |
| 65 | +jobs: |
| 66 | + some-job: |
| 67 | + runs-on: ubuntu-latest |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Checkout code |
| 71 | + uses: actions/checkout |
| 72 | + |
| 73 | + - name: Use custom action 1 |
| 74 | + uses: instructlab/ci-actions/custom-action-1@main |
| 75 | + |
| 76 | + - name: Use custom action 2 |
| 77 | + uses: instructlab/ci-actions/custom-action-2@main |
| 78 | +``` |
| 79 | +
|
| 80 | +Reference: [StackOverflow - "How to Publish Multiple GitHub Actions from a Single Repo and Call Them from Another Repo"](https://stackoverflow.com/a/79100136) |
0 commit comments