You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GitHub Actions中配置Google Cloud Run元数据?

问题解决:GitHub Action部署Cloud Run的metadata正确格式

你当前的问题在于google-github-actions/deploy-cloudrun的metadata参数要求是多行字符串格式的键值对(每行一个key=value),而不是YAML嵌套对象。下面是修正后的正确配置:

修正后的Deploy to Cloud Run步骤

- name: Deploy to Cloud Run
  env:
    GIT_TAG: ${{ steps.increment-git-tag.outputs.git-tag }}
  uses: google-github-actions/deploy-cloudrun@v0
  with:
    service: my-service
    image: 'gcr.io/${{ env.PROJECT_ID }}/${{ env.IMAGE_NAME }}:${{ env.GIT_TAG }}'
    region: ${{ env.REGION }}
    secrets: |
      /app/path/to/my-secret=my-secret:latest
    metadata: |
      min-instances=1
      max-instances=1
      ingress=internal
      tag=${{ env.GIT_TAG }}
      no-cpu-throttling=true
      command=node
      args=/app/path/to/main.js arg-1

关键说明

  • 所有metadata配置项都要放在|开头的多行字符串里,每行遵循key=value格式
  • 布尔值直接写true/false即可,无需引号
  • 多参数的args用空格分隔成单个字符串,无需换行
  • 你需要的核心配置已正确映射:
    • min-instances=1/max-instances=1:设置实例的最小/最大数量
    • ingress=internal:仅允许内部流量访问服务
    • no-cpu-throttling=true:保持CPU持续运行,空闲时不会节流
    • tag=${{ env.GIT_TAG }}:为服务打上对应Git标签的版本标识

内容的提问来源于stack exchange,提问作者Ozymandias

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.26 04:09:22