| # Licensed to the Apache Software Foundation (ASF) under one |
| # or more contributor license agreements. See the NOTICE file |
| # distributed with this work for additional information |
| # regarding copyright ownership. The ASF licenses this file |
| # to you under the Apache License, Version 2.0 (the |
| # "License"); you may not use this file except in compliance |
| # with the License. You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, |
| # software distributed under the License is distributed on an |
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| # KIND, either express or implied. See the License for the |
| # specific language governing permissions and limitations |
| # under the License. |
| |
| # This workflow modifies the GCP User Roles when the infra/users.yml file is updated. |
| # It applies the changes using Terraform to manage the IAM roles for users defined in the users.yml |
| |
| name: Modify the GCP User Roles according to the infra/users.yml file |
| |
| on: |
| workflow_dispatch: |
| # Trigger when the users.yml file is modified on the main branch |
| push: |
| branches: |
| - main |
| paths: |
| - 'infra/iam/users.yml' |
| |
| # This allows a subsequently queued workflow run to interrupt previous runs |
| concurrency: |
| group: '${{ github.workflow }} @ ${{ github.event.issue.number || github.sha || github.head_ref || github.ref }}-${{ github.event.schedule || github.event.comment.id || github.event.sender.login }}' |
| cancel-in-progress: true |
| |
| #Setting explicit permissions for the action to avoid the default permissions which are `write-all` in case of pull_request_target event |
| permissions: |
| contents: read |
| |
| jobs: |
| beam_UserRoles: |
| name: Apply user roles changes |
| runs-on: [self-hosted, ubuntu-20.04, main] |
| timeout-minutes: 30 |
| steps: |
| - uses: actions/checkout@v4 |
| - name: Setup gcloud |
| uses: google-github-actions/setup-gcloud@v2 |
| - name: Install Terraform |
| uses: hashicorp/setup-terraform@v3 |
| with: |
| terraform_version: 1.12.2 |
| - name: Initialize Terraform |
| working-directory: ./infra/iam |
| run: terraform init |
| - name: Terraform Plan |
| working-directory: ./infra/iam |
| run: terraform plan -out=tfplan |
| - name: Terraform Apply |
| working-directory: ./infra/iam |
| run: terraform apply -auto-approve tfplan |