Skip to content

Commit d8cb73e

Browse files
committed
ci: restrict workflows to run only on main repo
Prevent workflows from running on forks by adding repository owner checks to workflows that publish artifacts or use self-hosted runners. - Add check to `push.yaml` to prevent image publishing on forks - Add check to `release.yaml` to prevent release creation on forks - Add check to `k8s-bm.yaml` to prevent self-hosted runner usage on forks - Add check to `profiling.yaml` to prevent self-hosted runner usage on forks This ensures fork contributors don't need to manually disable workflows and prevents unnecessary runs on forks. Signed-off-by: vprashar2929 <[email protected]>
1 parent 9ae7700 commit d8cb73e

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

.github/workflows/k8s-bm.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
3232
build-and-deploy:
3333
needs: [check-changes]
34-
if: needs.check-changes.outputs.changes == 'true'
34+
if: needs.check-changes.outputs.changes == 'true' && github.repository_owner == 'sustainable-computing-io'
3535
runs-on: self-hosted
3636
steps:
3737
# NOTE: In case of self-hosted runners, tools like docker, make, kubectl etc. are installed at the time of setting up the runner.

.github/workflows/profiling.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
2626
profiling:
2727
needs: check-changes
28-
if: needs.check-changes.outputs.changes == 'true'
28+
if: needs.check-changes.outputs.changes == 'true' && github.repository_owner == 'sustainable-computing-io'
2929
runs-on: self-hosted
3030
steps:
3131
# NOTE: In case of self-hosted runners, tools like docker, make, kubectl etc. are installed at the time of setting up the runner.

.github/workflows/push.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
uses: ./.github/workflows/scorecard.yml
1616

1717
publish:
18+
if: github.repository_owner == 'sustainable-computing-io'
1819
runs-on: ubuntu-latest
1920
steps:
2021
- name: Checkout source

.github/workflows/release.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on: # yamllint disable-line rule:truthy
77

88
jobs:
99
release:
10+
if: github.repository_owner == 'sustainable-computing-io'
1011
permissions:
1112
contents: write
1213

0 commit comments

Comments
 (0)