Authenticating Action with GCP project (secrets)


I’m learning how to use Actions. I am trying to deploy a Cloud Function to my GCP project and I need to authenticate into the project. I have the json formatted file which is linked to a Service Account that has permissions.

I have created a secret in the settings options and tried to reference it in the workflow but I keep getting errors. The documentation is not as clear how this should be configured.

Does anyone have experience with this?

    - uses: actions/checkout@v2
    - id: deploy
      uses: google-github-actions/deploy-cloud-functions@main
        name: hello-wprld
        runtime: nodejs10
        credentials: ${{ secrets.nk_sandbox }}

the error:
Unexpected token � in JSON at position 0

That implies to me there is some sort of special or hidden character in your json file that you copied into the secret.

Thanks for the reply Micky!

I managed to get that working. The function gets created in GCP. But I’m getting another error which doesn’t make sense. I’m using the basic hello world function from Google GitHub. It has you clone their repo which includes one index.js file. Yet the error says “Build failed: function.js does not exist”.

So I’m not even sure how to go about troubleshooting that.

Do you have this in a public repo where I could take a look?

I’m having the same issue that funciton.js does not exist if I use google-github-actions/deploy-cloud-functions@main.
I also see that error if I manually upload a zip file using the Cloud Console GUI, but it deploys successfully if I use the GUI’s Inline Editor.

Did you ever find a solution to this?