aws-secrets-manager-actions icon indicating copy to clipboard operation
aws-secrets-manager-actions copied to clipboard

Change file output to end with newline?

Open gtwilliams03 opened this issue 2 years ago • 2 comments

I am using this great package for some GitHub Actions which export some environment variables to a file. One issue I am running into is that I am using DamianReeves/write-file-action to append additional environment variables to the outputted file. However, because of the limitations of .yml files, I am unable to insert a preceeding line break in the DamianReeves/write-file-action content property, so the appended items corrupt the last line of the output file from your action. I think this would be easily solved if the output file content has all items output with a newline at the end.

In order to make all lines end with a newline (including the last line), would it be acceptable to change this line:

      const secretsAsEnv = Object.entries(parsedSecret).map(([key, value]) => `${key}=${value}`).join('\n')

to this:

      const secretsAsEnv = Object.entries(parsedSecret).map(([key, value]) => `${key}=${value}\n`)

gtwilliams03 avatar Dec 01 '22 17:12 gtwilliams03

Sorry I can't understand seriously. Could you show me usage gh action code with DamianReeves/write-file-action?

say8425 avatar Dec 02 '22 04:12 say8425

Sure - this is showing leaving a blank line in the DamianReeves/write-file-action routine:

    - name: Export ENV from AWS Secret Manager
      uses: say8425/aws-secrets-manager-actions@v2
      with:
         SECRET1: ${{ secrets.SECRET1 }}
         SECRET2: ${{ secrets.SECRET2 }}
         OUTPUT_PATH: '.env' # optional
       
    - name: Append text to .env file
      uses: "DamianReeves/write-file-action@master"
      with:
        path: '.env'
        contents: |
          SECRET3=${{ secrets.SECRET3 }}

        write-mode: append

Would result in an .env file of:

SECRET1=***
SECRET2=***SECRET3=***

gtwilliams03 avatar Mar 20 '23 21:03 gtwilliams03