0

I´m trying to a deploy pipe with Github and Google Cloud using cloud run cause´ i´m using docker containers in the server, this is my GitHub action code (workflow)

name: Build and Deploy to Cloud Run


on:
  push:
    branches:
    - master

env:
  PROJECT_ID: ${{ secrets.RUN_PROJECT }}
  RUN_REGION: us-west2-a
  SERVICE_NAME:  helloworld-python

jobs:
  setup-build-deploy:
    name: Setup, Build, and Deploy
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v2

    # Setup gcloud CLI
    
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.9'
    - uses: google-github-actions/setup-gcloud@v0
      with:
        version: '390.0.0'
        service_account_email: ${{ secrets.ACC_MAIL }}
        service_account_key: ${{ secrets.RUN_SA_KEY }}
        project_id: ${{ secrets.RUN_PROJECT }}
    
    # Build and push image to Google Container Registry
    - name: Build
      run: |-
        gcloud builds submit \
          --quiet \
          --tag "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA"
    # Deploy image to Cloud Run
    - name: Deploy
      run: |-
        gcloud run deploy "$SERVICE_NAME" \
          --quiet \
          --region "$RUN_REGION" \
          --image "gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA" \
          --platform "managed" \
          --allow-unauthenticated

Everything seems to be "correct" but the moment I run the workflow, this error appears

ERROR: (gcloud.builds.submit) The required property [project] is not currently set.
You may set it for your current workspace by running:

  $ gcloud config set project VALUE

or it can be set temporarily by the environment variable [CLOUDSDK_CORE_PROJECT]

The proyect ID is in the RUN_PROYECT secret, I don´t know what else to do

Is there any problem that is not letting the thing work?

Edited: Changing the version to 390.0.0 worked, but now I´m receiving this error

ERROR: (gcloud.builds.submit) Invalid value for [source]: Dockerfile required when specifying --tag
  • 1
    See https://github.com/google-github-actions/setup-gcloud#authorization i.e. "**This action installs the Cloud SDK (gcloud). To configure its authentication to Google Cloud, use the google-github-actions/auth action.**" – Azeem Jan 12 '23 at 17:32
  • That helped, but now I´m encountering another error, i thougt this was goint to be a lot easier – RicardoRuizQ Jan 12 '23 at 18:23
  • Please update your question with the updated configuration and the error. – Azeem Jan 12 '23 at 18:25
  • Done, thanks a lot, the edited part is at the end – RicardoRuizQ Jan 12 '23 at 19:17
  • No problem. Please see this thread (https://stackoverflow.com/questions/58327157/specify-dockerfile-for-gcloud-build-submit). The Dockerfile is missing in the `gcloud builds submit` command after `--tag` flag. – Azeem Jan 13 '23 at 04:35

1 Answers1

1

For the first error:

ERROR: (gcloud.builds.submit) The required property [project] is not currently set.
You may set it for your current workspace by running:

  $ gcloud config set project VALUE

or it can be set temporarily by the environment variable [CLOUDSDK_CORE_PROJECT]

the gcloud command has not been properly configured.

According to the Authorization section of google-github-actions/setup-gcloud:

This action installs the Cloud SDK (gcloud). To configure its authentication to Google Cloud, use the google-github-actions/auth action.

So, you need to configure it for authorization using any one of the supported methods there.


For your second error:

ERROR: (gcloud.builds.submit) Invalid value for [source]: Dockerfile required when specifying --tag

the /path/to/Dockerfile is missing. You need to specify it in gcloud builds submit command.

See this relevant SO thread for more details: Specify Dockerfile for gcloud build submit

Azeem
  • 11,148
  • 4
  • 27
  • 40