GitHub Action认证报错:需指定workload_identity_provider或credentials_json其一
GitHub Action谷歌云认证报错排查:必须指定workload_identity_provider或credentials_json
问题详情
执行GitHub Action工作流的谷歌云认证步骤时,触发如下报错:
Error: Action failed with error: Error: The GitHub Action workflow must specify exactly one of "workload_identity_provider" or "credentials_json"!
当前使用的GHA YAML代码片段:
steps: - name: git checkout uses: actions/checkout@v3 - id: auth name: Authenticate to Google Cloud uses: google-github-actions/auth@v0.4.0 with: credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_DEV_2 }}'
此前使用credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}'时认证流程正常,更换密钥名称后出现上述错误。
解决方法
- 检查新密钥的GitHub Secrets配置:
报错核心原因是GOOGLE_APPLICATION_CREDENTIALS_DEV_2这个Secret未在当前仓库/组织的Secrets中配置,或配置内容为空。此时credentials_json参数无有效值传入,触发了Action的参数校验规则。 - 核对Secret名称的准确性:
GitHub Secrets区分大小写,确认密钥名称的拼写、大小写、下划线等完全匹配,避免因名称不一致导致无法读取。 - 验证密钥内容格式:
确保新密钥的内容是有效的谷歌云服务账号JSON格式,和之前正常使用的GOOGLE_APPLICATION_CREDENTIALS密钥格式一致,无内容遗漏或语法错误。
内容的提问来源于stack exchange,提问作者Aseem
相关产品推荐
相关产品推荐

