Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change file output to end with newline? #126

Open
gtwilliams03 opened this issue Dec 1, 2022 · 2 comments
Open

Change file output to end with newline? #126

gtwilliams03 opened this issue Dec 1, 2022 · 2 comments
Labels
🐛 bug Heterocera

Comments

@gtwilliams03
Copy link

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`)
@say8425
Copy link
Owner

say8425 commented Dec 2, 2022

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

@gtwilliams03
Copy link
Author

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=***

@say8425 say8425 added the 🐛 bug Heterocera label Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Heterocera
Projects
None yet
Development

No branches or pull requests

2 participants