sindresorhus/refined-github

Show next scheduled time of a GitHub Action #3104

notlmn posted onGitHub

GitHub shows a list of historical runs for a specific deployment in order. Some of these Actions could have been triggered from a scheduled run, with cron. But we do not know when the next scheduled run is going to be.

We could add an information bar here on the top if there is going to be a scheduled job for that Action and when.

image

This feature request is similar to what Travis shows in their cron job settings, like "Scheduled in 20 hours from now".

image

This can be computed based on the last scheduled run of an Action added with the schedule values for that Action.

Example: https://github.com/notlmn/copy-as-markdown/actions?query=workflow%3ADeployment


GitHub Actions needs so much work still...

This suggestion sounds good, maybe we can display it here:

<img width="301" alt="" src="https://user-images.githubusercontent.com/1402241/82212888-8c919180-9913-11ea-83cc-fd13c7130515.png">

But... we need an API for this, we can't load a YAML parser. Best case scenario GitHub lets us read configs as JSON (?) so we only need a lightweight cronjob parser module

posted by fregante almost 5 years ago

I tried a bit but couldn't find an API for that, the closest I could find was listing workflows and details of a workflow.

But these are v3, couldn't find anything related to actions or workflows in v4.

/cc @lukehefson

posted by notlmn almost 5 years ago

Impossible for the time being due to:

  • the size of YAML parsers (however this could be replaced with a "works for most" regex line /-\scron:\s+['"](.+)['"]/)
  • the size of cronjob parsers (I can't find anything under 500K (minified!), e.g. https://bundlephobia.com/result?p=recron@1.0.3)
posted by fregante over 4 years ago

✅ The YAML regex would be enough to extract it.

💡 The crontab parser doesn't have to be huge. I found a 11KB implementation but it'd have to be reverse-engineered: crontab-parser.zip

posted by fregante over 4 years ago

💡 The crontab parser doesn't have to be huge. I found a 11KB implementation but it'd have to be reverse-engineered: crontab-parser.zip

This sounds like an interesting exercise, I'll try my hand at it.

posted by cheap-glitch over 4 years ago

If you do send a PR, make sure to drop all unrelated code, like warnings and such. We only need to know when the next run is.

posted by fregante over 4 years ago

Published https://www.npmjs.com/package/@cheap-glitch/mi-cron if you want to use it for this issue. I wish I could help more with this but I know zilch about Github Actions.

posted by cheap-glitch over 4 years ago

Thank you!

To fix this issue, there's little to know about GH Actions, it just needs to:

  1. Fetch all (or the visible ones) workflows’ YML files in the most efficient way possible (should be one HTTP request)
  2. Find the cron line with regex: /-\scron:\s+['"](.+)['"]/)
  3. Parse it and use the relative-time element to display it on the sidebar of https://github.com/sindresorhus/refined-github/actions, as shown in my mockup:

<img width="301" alt="" src="https://user-images.githubusercontent.com/1402241/82212888-8c919180-9913-11ea-83cc-fd13c7130515.png">

posted by fregante over 4 years ago

Thanks @fregante for the detailed break up! Do you have any example(s) of similar feature(s) that can help me get started on this?

posted by cheap-glitch over 4 years ago

@cheap-glitch which part do you need help with.

If you ask me start with a dummy cron (dont fetch the yaml) and then we can work on getting the yaml

posted by yakov116 over 4 years ago

If you ask me start with a dummy cron (dont fetch the yaml) and then we can work on getting the yaml

The last time I worked on this, if I remember it right, we'll have to fetch all yaml files in .github/workflows and compare them with entries (of action names) on the actions page, would probably require caching too.

posted by notlmn over 4 years ago

Good point. If the filenames aren’t available in the sidebar, then the regex will also have to parse name:

posted by fregante over 4 years ago

If you ask me start with a dummy cron (dont fetch the yaml) and then we can work on getting the yaml

That was the plan, as I think the fetching part is what's gonna give me the most trouble.

Turns out this wasn't as hard as I thought it'd be.

posted by cheap-glitch over 4 years ago

Fund this Issue

$0.00
Funded

Pull requests