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

Line chomping not working as expected #19

Open
mortocks opened this issue Dec 5, 2022 · 0 comments
Open

Line chomping not working as expected #19

mortocks opened this issue Dec 5, 2022 · 0 comments

Comments

@mortocks
Copy link

mortocks commented Dec 5, 2022

Trying to use the action to update a csv file but line breaks don't seem to be working with YAML block chomping (keep).

Example below reads a new issue and adds to a csv.

on:
  issues:
    types:
      - opened

jobs:
  label_issue:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        name: Checkout
      - name: Append file
        uses: DamianReeves/write-file-action@master
        with:
          path: data.csv
          contents: |+
            ${{ github.event.issue.title }},${{ github.event.issue.body }}
              
          write-mode: append
      - name: Commit & Push
        uses: stefanzweifel/git-auto-commit-action@v4
        with:
          # github_token: ${{ secrets.GITHUB_TOKEN }}
          file_pattern: 'data.csv'
          branch: main
          commit_message: 'Overwritten by Github Actions - ${date}'

I tried using https://yaml-online-parser.appspot.com to parse the yaml to check the block chomping |+ setting and it appears to be correct (replacing GitHub vars with cell1,cell2,cell3 e.g

          contents: |+
            cell1,cell2,cell3
              
          write-mode: append

The output includes multiple \n\n at the end of the string as expected but when running within the action, it just appends the last line without line breaks.

Also strange, it appears to work differently on the first run - hope this makes sense.

Step 1
Start data.csv with single line for columns (no line breaks)

Heading1,Heading2,Heading3

Step 2
Run the action. Result is

Heading1,Heading2,Heading3
cell1,cell2,cell3

Works perfectly. Exactly what I'm after

Step3
Run action again, Result is

Heading1,Heading2,Heading3
cell1,cell2,cell3,cell1,cell2,cell3

The second time around, the |+ setting doesn't seem respected and the last line does not include line breaks

I think my YAML is formatted correctly but happy to be told I'm making YAML mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant