Skip to content

Commit

Permalink
[GHA] Avoid running actions in forks
Browse files Browse the repository at this point in the history
  • Loading branch information
akladiev committed Sep 23, 2024
1 parent cda1cbd commit b6ba11a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/actions/smart-ci/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ inputs:
description: "Comma-separated list of patterns (fnmatch-style). If PR has only matching files changed,
return indicator that CI can be skipped"
required: false
enable_for_org:
description: "Enables running workflows for a given organization; triggers from other orgs are skipped"
required: false
default: "openvinotoolkit"

outputs:
all_components:
Expand Down Expand Up @@ -99,6 +103,7 @@ runs:
-c "${{ inputs.components_config }}" \
-m "${{ inputs.components_config_schema }}" \
-l "${{ inputs.labeler_config }}" \
--enable_for_org "${{ inputs.enable_for_org }}" \
--skip-when-only-listed-labels-set "${{ inputs.skip_when_only_listed_labels_set }}" \
--skip-when-only-listed-files-changed "${{ inputs.skip_when_only_listed_files_changed }}"
shell: bash
Expand Down
7 changes: 7 additions & 0 deletions .github/actions/smart-ci/smart_ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ def parse_args():
parser.add_argument('--skip-when-only-listed-files-changed',
help="Comma-separated list of patterns (fnmatch-style). If PR has only matching files changed, "
"return indicator that CI can be skipped")
parser.add_argument('--enable_for_org', default='openvinotoolkit',
help='Enable running workflows for a given organization; triggers from other orgs are skipped')
args = parser.parse_args()
return args

Expand Down Expand Up @@ -243,6 +245,11 @@ def main():
logger.info(f"All changes are marked for skip, workflow may be skipped")
set_github_output("skip_workflow", str(skip_workflow))

if owner != args.enable_for_org:
logger.info(f"Running workflows is enabled only for repos in {args.enable_for_org} organization. "
f"The current workflow was initiated from other org: {owner}, skipping")
set_github_output("skip_workflow", "True")

# Syntactic sugar for easier use in GHA pipeline
affected_components_output = {name: {s: True for s in scope} for name, scope in affected_components.items()}
set_github_output("affected_components", json.dumps(affected_components_output))
Expand Down

0 comments on commit b6ba11a

Please sign in to comment.