question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AS_TOOK returns undefined when ran in multiple parallel workflow jobs

See original GitHub issue

Code used in multiple parallel jobs:

- name: Notify Slack
        if: contains(steps.deploy.outputs.result, 'successfully deployed')
        uses: 8398a7/action-slack@v3
        with:
          status: custom
          fields: workflow,job,commit,repo,ref,author,took
          custom_payload: |
            {
              username: 'github-actions',
              attachments: [{
                color: 'good',
                text: `blabla was successfully deployed with commit: ${process.env.AS_COMMIT} by ${{ github.actor }} via ${process.env.AS_WORKFLOW} & took ${process.env.AS_TOOK} to complete.`,
              }]
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEPLOYMENTS }}

Returns: image

Jobs look like this int he visual graph: image

It also happens when there is a single slack notif job that runs on its own, but still depends on multiple previous parallel jobs.

same code works for a job that’s not ran in parallel with others

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
8398a7commented, Apr 12, 2021

Thank you. I will investigate based on this.

0reactions
dimisjimcommented, Apr 13, 2021

I’ve done it the hacky way, using the GET /repos/{owner}/{repo}/actions/runs/{run_id} | jq -r '.created_at' API and doing a comparison like this, in a self-hosted centos 7 based runner:

      - name: Get workflow Run ID
        uses: octokit/request-action@v2.x
        id: workflowRunId
        with:
          route: GET /repos/org/repo/actions/runs/${{ github.run_id }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          
      - name: Get time diff between now and workflow run creation time
        id: workflowDuration
        run: |
          rpm -qa | grep dateutils || rpm -i https://download.opensuse.org/repositories/utilities/RHEL_7/x86_64/dateutils-0.4.4-44.1.x86_64.rpm
          NOW=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
          DIFF=`ddiff -i "%Y-%m-%dT%H:%M:%SZ" "${{ fromJson(steps.workflowRunId.outputs.data).created_at }}" $NOW -f "%H°%M'%S\" to complete."`
          echo "::set-output name=time::$(echo $DIFF)"
      - name: Notify Slack
        uses: 8398a7/action-slack@v3
        with:
          status: custom
          fields: workflow,job,commit,repo,ref
          custom_payload: |
            {
              username: 'github-actions',
              attachments: [{
                color: 'good',
                text: `Took ${{ steps.workflowDuration.outputs.time }}`,
              }]
            }
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL_DEPLOYMENTS }}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using jobs in a workflow
A workflow run is made up of one or more jobs , which run in parallel by default. To run jobs sequentially, you...
Read more >
Multiple parallel undefined BackgroundWorker [duplicate]
1 Answer 1 ... I would recommend using Tasks instead of Backgroundworkers.You can run as many Tasks as you wish in a simple...
Read more >
Run jobs in parallel with workflows to decrease your build ...
Learn how to use parallelism and workflows in your continuous integration and delivery (CI/CD) pipelines on CircleCI to improve efficiency ...
Read more >
Create, run, and manage Azure Databricks Jobs
A workspace is limited to 1000 concurrent job runs. A 429 Too Many Requests response is returned when you request a run that...
Read more >
Parallel steps | Workflows
A branch is a named set of steps that execute sequentially. Parallel branches can execute concurrently (with the steps in each branch executing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found