mirror of
https://github.com/google-github-actions/setup-gcloud.git
synced 2026-08-21 03:49:27 +00:00
chore: support WIF in example workflows
This commit is contained in:
parent
58c3a9aff9
commit
a9839f1d99
7 changed files with 129 additions and 28 deletions
|
|
@ -142,7 +142,7 @@ job:
|
|||
- id: auth
|
||||
uses: google-github-actions/auth@v0
|
||||
with:
|
||||
credentials_json: ${{ secrets.gcp_credentials }}
|
||||
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
|
||||
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0.3.0
|
||||
|
|
|
|||
|
|
@ -28,17 +28,32 @@ jobs:
|
|||
name: Setup, Build, and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup gcloud CLI
|
||||
- uses: google-github-actions/setup-gcloud@master
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
version: '286.0.0'
|
||||
service_account_email: ${{ secrets.RUN_SA_EMAIL }}
|
||||
service_account_key: ${{ secrets.RUN_SA_KEY }}
|
||||
project_id: ${{ secrets.RUN_PROJECT }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
# Build and push image to Google Container Registry
|
||||
- name: Build
|
||||
|
|
|
|||
|
|
@ -26,15 +26,33 @@ env:
|
|||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0.2.0
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
project_id: ${{ env.PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
- name: Authorize Docker push
|
||||
run: gcloud auth configure-docker
|
||||
|
|
|
|||
|
|
@ -23,15 +23,33 @@ jobs:
|
|||
deploy:
|
||||
name: Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0.2.0
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
project_id: ${{ env.PROJECT_ID }}
|
||||
service_account_key: ${{ secrets.GCP_SA_KEY }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
- name: Deploy to App Engine
|
||||
run: gcloud app deploy --quiet
|
||||
|
|
|
|||
26
example-workflows/gce/.github/workflows/gce.yaml
vendored
26
example-workflows/gce/.github/workflows/gce.yaml
vendored
|
|
@ -29,16 +29,32 @@ jobs:
|
|||
name: Setup, Build, Publish, and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup gcloud CLI
|
||||
- uses: google-github-actions/setup-gcloud@master
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
version: '290.0.1'
|
||||
service_account_key: ${{ secrets.GCE_SA_KEY }}
|
||||
project_id: ${{ secrets.GCE_PROJECT }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
# Configure Docker to use the gcloud command-line tool as a credential
|
||||
# helper for authentication
|
||||
|
|
|
|||
|
|
@ -33,15 +33,32 @@ jobs:
|
|||
name: Setup, Build, Publish, and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup gcloud CLI
|
||||
- uses: google-github-actions/setup-gcloud@master
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
service_account_key: ${{ secrets.GKE_SA_KEY }}
|
||||
project_id: ${{ secrets.GKE_PROJECT }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
# Configure Docker to use the gcloud command-line tool as a credential
|
||||
# helper for authentication (https://cloud.google.com/artifact-registry/docs/docker/authentication)
|
||||
|
|
|
|||
25
example-workflows/gke/.github/workflows/gke.yml
vendored
25
example-workflows/gke/.github/workflows/gke.yml
vendored
|
|
@ -30,15 +30,32 @@ jobs:
|
|||
name: Setup and Deploy
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Add "id-token" with the intended permissions.
|
||||
permissions:
|
||||
contents: 'read'
|
||||
id-token: 'write'
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Setup gcloud CLI
|
||||
- uses: google-github-actions/setup-gcloud@master
|
||||
# Configure Workload Identity Federation and generate an access token.
|
||||
- id: 'auth'
|
||||
name: 'Authenticate to Google Cloud'
|
||||
uses: 'google-github-actions/auth@v0'
|
||||
with:
|
||||
service_account_key: ${{ secrets.GKE_SA_KEY }}
|
||||
project_id: ${{ secrets.GKE_PROJECT }}
|
||||
workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
|
||||
service_account: 'my-service-account@my-project.iam.gserviceaccount.com'
|
||||
|
||||
# Alternative option - authentication via credentials json
|
||||
# - id: 'auth'
|
||||
# uses: 'google-github-actions/auth@v0'
|
||||
# with:
|
||||
# credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
|
||||
|
||||
# Setup gcloud CLI
|
||||
- name: Set up Cloud SDK
|
||||
uses: google-github-actions/setup-gcloud@v0
|
||||
|
||||
# Get the GKE credentials so we can deploy to the cluster
|
||||
- run: |-
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue