Skip to content

Commit 64fa9fd

Browse files
committed
Update GCP User IAM workflow to use pull_request_target and adjust permissions for better security; change role for a user to beam_viewer for testing
1 parent 5675d57 commit 64fa9fd

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

.github/workflows/beam_Infrastructure_UsersPermissions.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ on:
3030
- main
3131
paths:
3232
- 'infra/iam/users.yml'
33-
pull_request:
33+
pull_request_target:
34+
types: [opened, synchronize, reopened]
3435
paths:
3536
- 'infra/iam/users.yml'
3637

@@ -41,7 +42,7 @@ concurrency:
4142

4243
#Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event
4344
permissions:
44-
contents: read
45+
contents: write
4546
pull-requests: write
4647

4748
jobs:
@@ -51,6 +52,8 @@ jobs:
5152
timeout-minutes: 30
5253
steps:
5354
- uses: actions/checkout@v4
55+
with:
56+
ref: ${{ github.event.pull_request.head.sha }}
5457
- name: Setup gcloud
5558
uses: google-github-actions/setup-gcloud@v3
5659
- name: Install Terraform
@@ -85,6 +88,6 @@ jobs:
8588
run: gh pr comment ${{ github.event.pull_request.number }} --body-file comment_body.txt
8689

8790
- name: Terraform Apply
88-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
91+
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'apache/beam'
8992
working-directory: ./infra/iam
9093
run: terraform apply -auto-approve tfplan

infra/iam/users.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
- username: enriquecaol04
368368
email: enriquecaol04@gmail.com
369369
permissions:
370-
- role: roles/viewer
370+
- role: projects/apache-beam-testing/roles/beam_viewer
371371
- username: eventarc-workflow-sa
372372
email: eventarc-workflow-sa@apache-beam-testing.iam.gserviceaccount.com
373373
permissions:

0 commit comments

Comments
 (0)