Skip to content

Commit 2622279

Browse files
authored
Merge pull request #73 from ruivieira/update-gha
ci(workflow): run build-and-push in upstream repository only
2 parents 633015b + 933f44e commit 2622279

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

.github/workflows/build-and-push.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,23 @@ on:
2020
paths:
2121
- 'detectors/*'
2222
- '.github/workflows/*'
23-
pull_request_target:
23+
pull_request:
2424
paths:
2525
- 'detectors/*'
2626
types: [labeled, opened, synchronize, reopened]
2727
jobs:
2828
# Ensure that tests pass before publishing a new image.
2929
build-and-push-ci:
3030
# Only run if:
31-
# 1. Tests completed successfully on target branches (from workflow_run trigger), OR
32-
# 2. Direct push/PR trigger (tests will run in parallel)
31+
# 1. Running in the trustyai-explainability/guardrails-detectors repository, AND
32+
# 2. Tests completed successfully on target branches (from workflow_run trigger), OR
33+
# 3. Direct push/PR trigger (tests will run in parallel)
3334
if: |
34-
(github.event_name == 'workflow_run' &&
35-
github.event.workflow_run.conclusion == 'success' &&
36-
contains(fromJSON('["main", "incubation", "stable"]'), github.event.workflow_run.head_branch)) ||
37-
(github.event_name != 'workflow_run')
35+
github.repository == 'trustyai-explainability/guardrails-detectors' &&
36+
((github.event_name == 'workflow_run' &&
37+
github.event.workflow_run.conclusion == 'success' &&
38+
contains(fromJSON('["main", "incubation", "stable"]'), github.event.workflow_run.head_branch)) ||
39+
(github.event_name != 'workflow_run'))
3840
runs-on: ubuntu-latest
3941
permissions:
4042
contents: read
@@ -63,12 +65,15 @@ jobs:
6365
mode: minimum
6466
count: 1
6567
labels: "ok-to-test, lgtm, approved"
66-
- uses: actions/checkout@v3
68+
- uses: actions/checkout@v4
6769
if: env.BUILD_CONTEXT == 'ci'
6870
with:
6971
ref: ${{ github.event.pull_request.head.sha }}
70-
- uses: actions/checkout@v3
72+
persist-credentials: false
73+
- uses: actions/checkout@v4
7174
if: env.BUILD_CONTEXT == 'main' || env.BUILD_CONTEXT == 'tag'
75+
with:
76+
persist-credentials: false
7277
#
7378
# Print variables for debugging
7479
- name: Log reference variables

0 commit comments

Comments
 (0)