因此,我尝试从 Github 操作将全新的应用程序部署到 Google App Engine,但收到此错误消息:
Failed to create cloud build: invalid bucket "<PROJECT_NUMBER>.cloudbuild-logs.googleusercontent.com"; default Cloud Build service account or user-specified service account does not have access to the bucket
我尝试使用标志:
--bucket gs://generic-app
指定默认存储桶之外的其他存储桶。我还尝试指定一个具有所有者角色的不同服务帐户(我知道有点过头了),导出它的密钥并将其传递到 credentials_json
属性中。但我收到同样的错误消息。为什么会出现这种情况?
完整的工作流程文件
name: Deploy to Goggle App Engine
on:
push:
branches:
- main
- staging
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Node.js and yarn
uses: actions/setup-node@v2
with:
node-version: '18'
- name: Install dependencies
run: yarn
- name: Build Node Project
run: yarn build
# Production
- name: Google Cloud Auth Production
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY_PRODUCTION }}'
project_id: ${{ secrets.GCP_PROJECT_ID_PRODUCTION }}
# Staging
- name: Google Cloud Auth Staging
if: github.event_name == 'push' && github.ref == 'refs/heads/staging'
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_SA_KEY_STAGING }}'
project_id: ${{ secrets.GCP_PROJECT_ID_STAGING }}
- name: Set up Cloud SDK
uses: 'google-github-actions/setup-gcloud@v2'
- name: Deploy to Google App Engine
run: |
gcloud app deploy app.yaml --quiet --version service-default --no-promote --bucket gs://generic-app
对于任何遇到同样问题的人。我只需要第一次使用我的常规(非服务)帐户在本地部署应用程序,并且使用服务帐户在 Github 上进行的所有后续部署操作都开始成功。
/耸肩