无法在GitHub Actions上使用服务密钥验证Google Cloud - JSON中位置0的意外令牌



我将服务帐户密钥JSON存储为秘密,文件中没有错误。然而,每次我运行该操作时,它都会抱怨一个意外的令牌。怎么了?

Error: google-github-actions/auth failed with: retry function failed after 1 attempt: failed to parse service account key JSON credentials: unexpected token  in JSON at position 0

服务帐号密钥格式:

{
"type": "service_account",
"project_id": "",
"private_key_id": "",
"private_key": "-----BEGIN PRIVATE KEY-----\n-----END PRIVATE KEY-----n",
"client_email": "",
"client_id": "",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": ""
}

工作流:

- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: $GOOGLE_CREDENTIALS
- id: 'upload-file'
name: 'Upload report to Google Cloud'
uses: 'google-github-actions/upload-cloud-storage@v0'
with:
path:  $GITHUB_WORKSPACE/mochawesome-report
destination: api-test-results
parent: false
glob: '*.html'
- uses: 'google-github-actions/upload-cloud-storage@v0'
if: always()
env:
SLACK_URL: ${{ secrets.SLACK_URL }}
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }}

可能是auth步骤中的错别字?试试:

- id: 'auth'
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GOOGLE_CREDENTIALS }}

代替:

with:
credentials_json: $GOOGLE_CREDENTIALS

相关内容

  • 没有找到相关文章

最新更新