Skip to content

failed with: failed to parse service account key JSON credentials: unexpected token #465

@steezeburger

Description

@steezeburger

TL;DR

I followed the docs and included my credentials json as a one line secret in an environment for my github action, yet I get this error

Error: google-github-actions/auth failed with: failed to parse service account key JSON credentials: unexpected token '�', "�*^���ǿi�("... is not valid JSON

Expected behavior

For it to accept the json in the secret

Observed behavior

It did not accept the json in the secret

Action YAML

name: Deploy to Google Cloud Functions

on:
  push:
    branches:
      - main  # or your default branch
  workflow_dispatch:  # allows manual triggers

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: cicd
    steps:
      - uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '>=22.0.0'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Build
        run: npm run build

      - id: 'auth'
        uses: google-github-actions/auth@v2
        with:
          credentials_json: '${{ secrets.GCP_SA_KEY }}'
          project_id: ${{ vars.GCP_PROJECT_ID }}

      - name: Setup Google Cloud SDK
        uses: google-github-actions/setup-gcloud@v2
        with:
          project_id: ${{ vars.GCP_PROJECT_ID }}

      - name: Deploy to Cloud Run Functions
        run: |
          just deploy

Log output

Run google-github-actions/auth@v2
  with:
    credentials_json: ***
    project_id: swap-routing-api-dev
    create_credentials_file: true
    export_environment_variables: true
    universe: googleapis.com
    cleanup_credentials: true
    access_token_lifetime: 3600s
    access_token_scopes: https://www.googleapis.com/auth/cloud-platform
    id_token_include_email: false
Error: google-github-actions/auth failed with: failed to parse service account key JSON credentials: unexpected token '�', "�*^���ǿi�("... is not valid JSON

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions