organization-workflows icon indicating copy to clipboard operation
organization-workflows copied to clipboard

Re-run Actions Job doesn't work as expected.

Open alexandresavicki opened this issue 4 years ago • 6 comments

Hi @SvanBoxel

I'm doing more tests with this app and I found a strange scenario.

My central workflow runs a custom bash script, to search specific values ​​in a specific file in my repositories. If my script fail for some BUG, ​​i'm going to fix it in my central workflow repository and try to Re-run my action job.

After to Re-run the Action job the checks that failed before, changed your status to pending and check has stuck with this status even though my job has passed.

image

image

image

How does the application work with this scenario? Is it expected to return the status of an action job that has been performed again?

alexandresavicki avatar Jan 27 '21 18:01 alexandresavicki

Hi @alexandresavicki. This is a known issue I've encountered before. The token that is used has an expiry of 1 hour. So retriggering the workflow after an hour will result in a token that can't be used. Could you share the log output of the workflow?

SvanBoxel avatar Jan 29 '21 08:01 SvanBoxel

Hi @SvanBoxel shure.

Here my log output of the workflow: image

As you can see, my job has passed, but in my PR keeps at In progress status

image

Also i would like to add the App logs bellow, i hope help you.

INFO     (http): POST / 200 - 150ms
DEBUG    (github): GitHub request: GET https://api.github.com/repos/OrgWorkFlow/.github/contents/.github%2Fworkflows%2Fenforce-checklist-file.md - 200
DEBUG    (Enforce checklist file): GitHub request: POST https://api.github.com/repos/OrgWorkFlow/example-app/check-runs - 201
    head_sha: "e5bb5cd136fe3e1909fe0607eba8643158705200"
    details_url: "https://github.com/OrgWorkFlow/.github/actions/runs/525847984"
    status: "in_progress"
    output: {
      "title": "Enforce checklist file",
      "summary": "# Enforce Checklist compliance\n\nThis workflow checks whether you've used checklist in your repository properly.\nOur script are defined [here](https://github.com/OrgWorkFlow/.github/blob/main/scripts/enforce-checklist-file.sh).\n\nIf you need more information about this check then please reach out to `#devops-team` on Slack.\n"
    }
INFO     (http): GET /register?id=601705bcf22d6f7aace2ec33&run_id=525847984&sha=e5bb5cd136fe3e1909fe0607eba8643158705200&enforce=false&enforce_admin=false&name=Enforce%20checklist%20file&documentation=.github%2Fworkflows%2Fenforce-checklist-file.md 200 - 2259ms
INFO     (http): POST / 200 - 3ms
INFO     (http): POST / 200 - 148ms
INFO     (http): POST / 200 - 1ms
INFO     (http): POST / 200 - 869ms

I can't see much information after rerun my workflow job. Let me know if you needs some more information.

alexandresavicki avatar Jan 31 '21 19:01 alexandresavicki

Thanks for sharing. I can confirm this has to do with the token expiration of 1 hour. This is a known limitation. I'll keep the issue open until there is a solution for this.

SvanBoxel avatar Feb 18 '21 18:02 SvanBoxel

Hey @SvanBoxel ! Firstly, great tool you made there 👍🏽

Since I'm having the same issue as @alexandresavicki, I was wondering if you knew how to fix it or at least an idea? 🤔

Context: I've clicked the "re-run" button, and now I'm having refs issues when trying to push to other repositories from the workflow. I'm updating a repository containing versions/images through the organization workflow whenever there's a push on the selected repos (configuration tab)

I've checked around your repo and found the /src/handlers/register.ts file, where it seems you're registering the workflow in the source repo, could we possibly implement a fix there?

I was thinking about two options :

  • Either renewing the token when the "re-run" button is clicked
    • By checking in the register step if the token is still valid
    • May be inspired by : https://github.com/marketplace/actions/workflow-application-token-action
  • Or by blocking/skipping the run to avoid any side effect (my current case)

Is this a workaround to cancel the "re-run" if the token is invalid : https://github.com/SvanBoxel/organization-workflows/issues/32#issuecomment-819838508 ?

I've seen that Github planned to implement "Organization workflows", at least it seems to be in their roadmap right?

If ever someone have a quick fix to stop/delete a registered run on the source repo, be my guest 🙏🏽

Is there anyone working on this, if ever I plan to contribute?

Cheers! 🍺

Grraahaam avatar Mar 02 '22 17:03 Grraahaam

I've been able to track down the root cause and it relates to the check_run resource created when registering the triggered workflow in the source repo, it gets stuck in the status: in_progress state and can't be updated with OAuth/PAT tokens (error "You must authenticate via a GitHub App") 😢

Using Github CLI

gh api -X GET "/repos/{owner}/{repo}/commits/main/check-runs"
{
  "total_count": 1,
  "check_runs": [
    {
      "id": 5393867758,
      "name": "Test workflow",
      "status": "in_progress",
      "completed_at": null,
      "conclusion": null,
      ...
    }
  ]
}

When I'm trying to update it :

gh api -X PATCH "/repos/{owner}/{repo}/check-runs/5393867758" -f status='completed' -f conclusion='success'
{
  "message": "You must authenticate via a GitHub App.",
  "documentation_url": "https://docs.github.com/rest/reference/checks#update-a-check-run"
}

I've found several posts about permission issues regarding OAuth/PAT on Checks API... (example)

Hope this can help you to debug ✌🏽

Edit: Here's my community post with the solution (deleting + recreating the impacted repo)

Grraahaam avatar Mar 03 '22 15:03 Grraahaam

Thank you for your investigation @Grraahaam. 🙇🏽

SvanBoxel avatar Mar 10 '22 07:03 SvanBoxel