9

I'm in the process of moving a working CircleCI workflow over to Github Actions.

I'm running:

runs-on: ubuntu-latest

container: 
  image: google/cloud-sdk:latest

I run the following command:

echo ${{ secrets.GCLOUD_API_KEYFILE }} > ./gcloud-api-key.json

Before running this command, gcloud-api-key.json has not yet been created. This command works in CircleCI but in Github Actions I get the error:

/__w/_temp/asd987as89d7cf.sh: 2: /__w/_temp/asd987as89d7cf.sh: type:: not found

Does anyone know what this error means?

3 Answers 3

10

The reason was because my secret key was more then 1 line long. Once I made it one line it worked.

Sign up to request clarification or add additional context in comments.

2 Comments

And how you echo things that are more than 1 line long?
@Vencovsky I solved it by enconding my data in base64 and decoding it to create the file, e.g.: echo ${{ secrets.GCLOUD_API_KEYFILE }} | base64 --decode > ./gcloud-api-key.json
3

In order to use secrets which contain more than just one line (like secret jsons) one has to save the base64 encoded secret in Github which makes it one line. On linux the encoding is done via:

cat mysecret.json | base64

Then in the action you need to decode it using

echo ${{ secrets.YOUR_SECRET }} | base64 -d > secret.json

1 Comment

P.S. If you want the base64 to output with no Enter lines, do cat mysecret.json | base64 -w 0
0

Use quotation marks for echo command:

run: echo "${{ secrets.YOUR_SECRET }}" > secret_file

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.