mirror of
https://github.com/google-github-actions/setup-gcloud.git
synced 2026-08-21 07:19:24 +00:00
63 lines
1.9 KiB
YAML
63 lines
1.9 KiB
YAML
# Copyright 2019 Google, LLC.
|
|
#
|
|
# Licensed 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.
|
|
|
|
name: Build using Cloud Build
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
env:
|
|
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
|
|
SERVICE_NAME: helloworld-nodejs
|
|
|
|
jobs:
|
|
setup-build-deploy:
|
|
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
|
|
|
|
# Configure Workload Identity Federation and generate an access token.
|
|
- id: 'auth'
|
|
name: 'Authenticate to Google Cloud'
|
|
uses: 'google-github-actions/auth@v0'
|
|
with:
|
|
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
|
|
run: |-
|
|
gcloud builds submit \
|
|
--quiet \
|
|
--tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
|