gcloudignore didn't work when deploying API to Cloud Run using GitHub Actions

This issue has been tracked since 2022-01-04.


Google Cloud Run cannot read .env. staging file when deployed using GitHub Actions, whereas I've included the .env.staging file in .gcloudignore.

This is my .gcloudignore:



Expected behavior

The .env.staging file should be exist in Cloud Run container and my API should be able to read it.

Observed behavior

My API cannot read the .env.staging file and caused deployment error when using Github Actions
Screenshot from 2022-01-04 14-29-25
Screenshot from 2022-01-04 14-28-39

Action YAML

name: CI/CD to Google Cloud Run

      - published

    name: Continous Deployment to Google Cloud Run
    runs-on: ubuntu-latest
      contents: read
      id-token: write

      - uses: actions/[email protected]

      - id: auth
        name: Authenticate service account
        uses: google-github-actions/[email protected]
          credentials_json: ${{secrets.SERVICE_ACCOUNT_JSON}}

      - id: gcloud
        name: Setup Google Cloud SDK
        uses: google-github-actions/[email protected]
          project_id: ${{secrets.GCP_PROJECT_ID}}

      - id: deploy
        name: Deploy API to Google Cloud Run
        run: gcloud builds submit --config deployments/cloudbuild.staging.yaml

Additional information

I don't know it's a bug or not, but when I deployed my API using gcloud command line locally, it worked fine. The error only happen when using Github Actions.

Any solutions?


sethvargo wrote this answer on 2022-01-04

Is .env.staging checked into the source repository?

ajipandean wrote this answer on 2022-01-04

Do you mean "is .env.staging pushed into the source repository?"? No, it isn't.

It ignored by git.

sethvargo wrote this answer on 2022-01-04

Then it wouldn't work with GitHub Actions. GitHub Actions clones the repo from GitHub.

ajipandean wrote this answer on 2022-01-04

Ahh I see. How can I didn't notice that thing :D thanks for that.

Is there any possible solution that I can use so I can implement automatic deployment for my API?

sethvargo wrote this answer on 2022-01-04

You would need to either check that value into source control or, if they values are sensitive, set them in GitHub Secrets.

More Details About Repo
Owner Name google-github-actions
Repo Name setup-gcloud
Full Name google-github-actions/setup-gcloud
Language TypeScript
Created Date 2019-11-05
Updated Date 2023-03-23
Star Count 1505
Watcher Count 65
Fork Count 548
Issue Count 11


Issue Title Created Date Updated Date