Unable to deploy to GAE from Github Actions

16 Views Asked by At

So I'm trying to deploy a brand new application to Google App Engine from Github actions and I'm getting this error message:

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

I have tried to specify a different bucket for logging other than the default, using the flag: --bucket gs://generic-app. I've also tried to specify a different service account that has owner role (overkill, I know), exported it's key and passed it into the credentials_json prop. But I get the same error message. Why would this be happening?

Full workflow file

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
1

There are 1 best solutions below

0
JayCodist On

For anyone getting this same issue. I simply needed to deploy the application locally for the first time, with my regular (non-service) account and all subsequent deployments on Github actions with the service account started succeeding.

/Shrug