Skip to content

Commit 470f45e

Browse files
feat(workflows): reduce restrictions for invoking workflows for private repos
1 parent 51fcbb2 commit 470f45e

File tree

4 files changed

+58
-12
lines changed

4 files changed

+58
-12
lines changed

.github/workflows/gemini-cli.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ permissions:
2929
jobs:
3030
gemini-cli:
3131
# This condition is complex to ensure we only run when explicitly invoked.
32+
# Users with access to private repos should be able to invoke gemini.
33+
# For public repos, only trusted users should be able to invoke gemini.
3234
if: |-
3335
github.event_name == 'workflow_dispatch' ||
3436
(
3537
github.event_name == 'issues' && github.event.action == 'opened' &&
3638
contains(github.event.issue.body, '@gemini-cli') &&
3739
!contains(github.event.issue.body, '@gemini-cli /review') &&
3840
!contains(github.event.issue.body, '@gemini-cli /triage') &&
39-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association)
41+
(
42+
github.event.repository.private == true ||
43+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association)
44+
)
4045
) ||
4146
(
4247
(
@@ -46,14 +51,20 @@ jobs:
4651
contains(github.event.comment.body, '@gemini-cli') &&
4752
!contains(github.event.comment.body, '@gemini-cli /review') &&
4853
!contains(github.event.comment.body, '@gemini-cli /triage') &&
49-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
54+
(
55+
github.event.repository.private == true ||
56+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
57+
)
5058
) ||
5159
(
5260
github.event_name == 'pull_request_review' &&
5361
contains(github.event.review.body, '@gemini-cli') &&
5462
!contains(github.event.review.body, '@gemini-cli /review') &&
5563
!contains(github.event.review.body, '@gemini-cli /triage') &&
56-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
64+
(
65+
github.event.repository.private == true ||
66+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
67+
)
5768
)
5869
timeout-minutes: 10
5970
runs-on: 'ubuntu-latest'

.github/workflows/gemini-pr-review.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ permissions:
3838

3939
jobs:
4040
review-pr:
41+
# This condition is complex to ensure we only run when explicitly invoked.
42+
# Users with access to private repos should be able to invoke gemini.
43+
# For public repos, only trusted users should be able to invoke gemini.
4144
if: |-
4245
github.event_name == 'workflow_dispatch' ||
4346
(
4447
github.event_name == 'pull_request' &&
45-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
48+
(
49+
github.event.repository.private == true ||
50+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
51+
)
4652
) ||
4753
(
4854
(
@@ -53,12 +59,18 @@ jobs:
5359
github.event_name == 'pull_request_review_comment'
5460
) &&
5561
contains(github.event.comment.body, '@gemini-cli /review') &&
56-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
62+
(
63+
github.event.repository.private == true ||
64+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
65+
)
5766
) ||
5867
(
5968
github.event_name == 'pull_request_review' &&
6069
contains(github.event.review.body, '@gemini-cli /review') &&
61-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
70+
(
71+
github.event.repository.private == true ||
72+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
73+
)
6274
)
6375
timeout-minutes: 5
6476
runs-on: 'ubuntu-latest'

examples/workflows/gemini-cli/gemini-cli.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,19 @@ permissions:
2929
jobs:
3030
gemini-cli:
3131
# This condition is complex to ensure we only run when explicitly invoked.
32+
# Users with access to private repos should be able to invoke gemini.
33+
# For public repos, only trusted users should be able to invoke gemini.
3234
if: |-
3335
github.event_name == 'workflow_dispatch' ||
3436
(
3537
github.event_name == 'issues' && github.event.action == 'opened' &&
3638
contains(github.event.issue.body, '@gemini-cli') &&
3739
!contains(github.event.issue.body, '@gemini-cli /review') &&
3840
!contains(github.event.issue.body, '@gemini-cli /triage') &&
39-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association)
41+
(
42+
github.event.repository.private == true ||
43+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.issue.author_association)
44+
)
4045
) ||
4146
(
4247
(
@@ -46,14 +51,20 @@ jobs:
4651
contains(github.event.comment.body, '@gemini-cli') &&
4752
!contains(github.event.comment.body, '@gemini-cli /review') &&
4853
!contains(github.event.comment.body, '@gemini-cli /triage') &&
49-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
54+
(
55+
github.event.repository.private == true ||
56+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
57+
)
5058
) ||
5159
(
5260
github.event_name == 'pull_request_review' &&
5361
contains(github.event.review.body, '@gemini-cli') &&
5462
!contains(github.event.review.body, '@gemini-cli /review') &&
5563
!contains(github.event.review.body, '@gemini-cli /triage') &&
56-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
64+
(
65+
github.event.repository.private == true ||
66+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
67+
)
5768
)
5869
timeout-minutes: 10
5970
runs-on: 'ubuntu-latest'

examples/workflows/pr-review/gemini-pr-review.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,17 @@ permissions:
3838

3939
jobs:
4040
review-pr:
41+
# This condition is complex to ensure we only run when explicitly invoked.
42+
# Users with access to private repos should be able to invoke gemini.
43+
# For public repos, only trusted users should be able to invoke gemini.
4144
if: |-
4245
github.event_name == 'workflow_dispatch' ||
4346
(
4447
github.event_name == 'pull_request' &&
45-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
48+
(
49+
github.event.repository.private == true ||
50+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
51+
)
4652
) ||
4753
(
4854
(
@@ -53,12 +59,18 @@ jobs:
5359
github.event_name == 'pull_request_review_comment'
5460
) &&
5561
contains(github.event.comment.body, '@gemini-cli /review') &&
56-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
62+
(
63+
github.event.repository.private == true ||
64+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
65+
)
5766
) ||
5867
(
5968
github.event_name == 'pull_request_review' &&
6069
contains(github.event.review.body, '@gemini-cli /review') &&
61-
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
70+
(
71+
github.event.repository.private == true ||
72+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
73+
)
6274
)
6375
timeout-minutes: 5
6476
runs-on: 'ubuntu-latest'

0 commit comments

Comments
 (0)