Result of run echo after github-script return empty string

Trying to get list of issues with particular label using github-script and output them with echo on schedule.

Issues:

  1. Workflow does not run on schedule, only after push
  2. Echo returns:
    Run echo “”
    echo “”
    shell: /bin/bash -e {0}

Action file:

name: Get list of PRs with label

on:
    schedule:
    - cron: '* * * * MON-FRI'

jobs:
    wait-for-check-job:
        runs-on: ubuntu-latest
        steps:
            - name: Get PRs with label 'Ready for Review"
              uses: actions/github-script@v3
              id: make-request
              with:
                  github-token: ${{secrets.GITHUB_TOKEN}}
                  script: |
                      github.issues.listForRepo({
                        owner: context.repo.owner,
                        repo: context.repo.repo,
                        labels: ["Ready for Review"]
                      })
            - name: Log output of the script
              run: echo "${{steps.make-request.outputs.result}}"

References used:

  1. schedule: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#scheduled-events
  2. gh-script: https://github.com/actions/github-script#reading-step-results
  3. request: https://octokit.github.io/rest.js/v18#issues / List repository issues

I believe this isn’t running because you’ve set the schedule to run every minute. Actions workflows can’t run on a period shorter than every 5 minutes so this may be stopping your workflow from running at all.

The shortest interval you can run scheduled workflows is once every 5 minutes.

You might need to change this to run every 5 minutes, or an even longer period if you prefer:
*/5 * * * MON-FRI

As for the empty result, I’m not :100: but it could be because this is in an array format? The docs ask for a comma separated list and it could be that this means a comma separated string. Can you try changing this to a string and see if it works?

Hi,

Thank you.

Earlier I changed workflow to one below, added simple js function but still cannot get how to pass output of the script to the next step(mean “Log output of the script” one).

name: Get list of PRs with label

on:
    schedule:
    - cron: '*/5 10-18 * * 1-5'

jobs:
    wait-for-check-job:
        runs-on: ubuntu-latest
        steps:
              - uses: actions/github-script@v3
                id: make-request
                with:
                  github-token: ${{secrets.GITHUB_TOKEN}}
                  script: |
                      let pulls = []
                      const result = await github.issues.listForRepo({
                        owner: context.repo.owner,
                        repo: context.repo.repo,
                        labels: ["Ready for Review"]
                      })
                      
                      function getPulls(){
                        result.data.forEach(function (arrayItem) {
                            pulls.push(arrayItem.html_url)
                        })
                      }
                      
                      getPulls()
                      
                      console.log(pulls) // logs what's needed
                      // return pulls // will try to ${{ steps.make-request.outputs.pulls }}  next
                     
                    
              - name: Log output of the script
                env:
                    RECEIVED: ${{ steps.make-request.outputs.result }}  
                run: echo $RECEIVED // empty

And my scheduled action seems running randomly instead of 5 mins expected: