简体   繁体   English

谷歌云,GitHub pipe 与谷歌云运行

[英]Google Cloud, GitHub pipe with Google Cloud Run

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)我正在尝试使用云运行部署 pipe 和 Github 和 Google Cloud,因为我在服务器中使用 docker 容器,这是我的 GitHub 操作代码(工作流程)

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项目 ID 在RUN_PROYECT秘密中,我不知道还能做什么

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编辑:将版本更改为 390.0.0 有效,但现在我收到此错误

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

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. gcloud命令正确配置。

According to the Authorization section of google-github-actions/setup-gcloud :根据google-github-actions/setup-gcloud授权部分:

This action installs the Cloud SDK ( gcloud ).此操作安装 Cloud SDK ( gcloud )。 To configure its authentication to Google Cloud, use the google-github-actions/auth action.要配置其对 Google Cloud 的身份验证,请使用google-github-actions/auth操作。

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. /path/to/Dockerfile 丢失。 You need to specify it in gcloud builds submit command.您需要在gcloud builds submit命令中指定它。

See this relevant SO thread for more details: Specify Dockerfile for gcloud build submit有关详细信息,请参阅此相关的 SO 线程: Specify Dockerfile for gcloud build submit

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM