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

Truncated output from Github Action #110

Closed
lyqht opened this issue Nov 30, 2021 · 8 comments
Closed

Truncated output from Github Action #110

lyqht opened this issue Nov 30, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@lyqht
Copy link

lyqht commented Nov 30, 2021

Describe the bug
Using the action with the following .yml of output_only=true

The output I got is truncated. An example can be seen from this workflow run under the Run cd /home/runner/work/_actions/lyqht/article-count-workflow/main && npm install && node articleCount.js command

Expected behavior
I don't actually require the full array of content, for my purposes, I just wanted to get the array count of the all the articles from the feeds.

Workflow Yml Used

  steps:
  - name: Checkout
    uses: actions/checkout@v2
  - name: Running Gautam's Blog post workflow 
    uses: gautamkrishnar/blog-post-workflow@master
    id: blogpost_workflow
    with:
      comment_tag_name: ${{inputs.comment_tag_name}}
      commit_message: "Updated Badge with latest number of articles"
      feed_list: ${{inputs.feed_list}}
      max_post_count: 1000000
      output_only: true
@lyqht lyqht added the bug Something isn't working label Nov 30, 2021
@gautamkrishnar
Copy link
Owner

gautamkrishnar commented Nov 30, 2021

The output is usually truncated due to Github's environment limits. The error message might show up as "Error: Argument list too long" if we try to echo the generated output.

Added a fix that redirects the generated JSON into a file (/tmp/blog_post_workflow_output.json) so that the users can consume the generated contents without using the github action's native echo commands.
You can now do something like:

  - name: Running Gautam's Blog post workflow 
    uses: gautamkrishnar/blog-post-workflow@master
    id: blogpost_workflow
    with:
      comment_tag_name: ${{inputs.comment_tag_name}}
      commit_message: "Updated Badge with latest number of articles"
      feed_list: ${{inputs.feed_list}}
      max_post_count: 1000000
      output_only: true
 - name: Echo the length
    run: echo $(jq '. | length' /tmp/blog_post_workflow_output.json)

@gautamkrishnar
Copy link
Owner

@lyqht
Copy link
Author

lyqht commented Dec 1, 2021

@gautamkrishnar , hello there, I'm getting a new error by following the instructions above in this workflow run

Sorry, I'm not very familiar with using jq 😅

> Run echo "::set-output name=articles_length::$(jq '. | length' /tmp/blog_post_workflow_output.json)"
  echo "::set-output name=articles_length::$(jq '. | length' /tmp/blog_post_workflow_output.json)"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
parse error: Invalid numeric literal at line 1, column 8

@gautamkrishnar
Copy link
Owner

@lyqht what are you trying to do, can you please explain the use case you are trying to achieve.

@gautamkrishnar
Copy link
Owner

gautamkrishnar commented Dec 1, 2021

@lyqht it was a bug 🤣 , fixed it. Please use the following code to get the length:

name: Latest blog post length
on:
  schedule:
    - cron: '*/5 * * * *'
  workflow_dispatch:
jobs:
  update-readme-with-blog:
    name: Update this repo's README with latest blog posts
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Insatall jq
        run: sudo apt install -y jq
      - uses: gautamkrishnar/blog-post-workflow@master
        with:
          commit_message: "Updated readme with the latest blogposts"
          feed_list: "https://esteetey.dev/rss.xml"
          max_post_count: 1000
          output_only: true
      - name: Saves count as an output
        id: count-step
        run: echo "::set-output name=articles_length::$(jq '. | length' /tmp/blog_post_workflow_output.json)"
      - name: Prints count
        run: echo ${{ steps.count-step.outputs.articles_length }}
 

Thanks for reporting it 😄

@lyqht
Copy link
Author

lyqht commented Dec 1, 2021

Able to get it now

env:
    articles_length: 18

Thank you for the fix 👍

@ProjectSoft-STUDIONIONS
Copy link

ProjectSoft-STUDIONIONS commented Jul 22, 2024

@gautamkrishnar
I'm returning to this topic.
Every time I try to output it to blog_post_workflow_output.json, I still get the same error.
And I created the tmp folder everywhere, in the root, in .github, in .github/workflows - everything is useless. I know that this will not affect the result, but still, trying is not torture.
And what do I think about this... The tmp folder simply does not exist, and we are trying to write a file to it. Accordingly, an error. L13931
At least that's how it is for me.
Maybe add the creation of this folder?
Like this:

fs.mkdirSync(path.join("/", "tmp"), {recursive: true});

@gautamkrishnar
Copy link
Owner

@ProjectSoft-STUDIONIONS that's strange. i will take a look at it when I have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants