Skip to content

Instantly share code, notes, and snippets.

@guitarrapc
Last active August 30, 2024 13:38
Show Gist options
  • Save guitarrapc/a49427e1bb57fb77584a38b5b3a93e6d to your computer and use it in GitHub Desktop.
Save guitarrapc/a49427e1bb57fb77584a38b5b3a93e6d to your computer and use it in GitHub Desktop.
List GitHub Actions workflow which has on.schedule
#/bin/bash
set -euo pipefaiil
echo "| Name | Path | Schedule (UTC) |"
echo "| ---- | ---- | ---- |"
json=$(gh workflow list --json name,path,state --limit 300)
echo "$json" | jq -c '.[] | select(.state == "active") | {name: .name, path: .path}' | sort | while read -r item; do
name=$(echo "$item" | jq -r '.name')
path=$(echo "$item" | jq -r '.path')
if [[ ! -f "$path" ]]; then continue; fi
schedule=$(cat "$path" | yq -o=json | jq -r 'select(.on.schedule != null) | [.on.schedule[].cron] | join("<br/>")')
if [[ -z "$schedule" ]]; then continue; fi
echo "| $name | $path | $schedule |"
done
Name Path Schedule(UTC)
foo .github/workflows/test-foo.yaml 0 18 * * 1-5
bar .github/workflows/test-bar.yaml 0 0 * * *
0 18 * * *
name: bar
on:
schedule:
- cron: "0 0 * * *"
- cron: "0 18 * * *"
name: foo
on:
workflow_dispatch:
schedule:
- cron: "0 18 * * 1-5"
name: val
on:
workflow_dispatch:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment