workflowIDFromPath extracts the workflow ID from a workflow path. e.g. ".github/workflows/smoke-antigravity.lock.yml" → "smoke-antigravity"
(path string)
| 16 | // workflowIDFromPath extracts the workflow ID from a workflow path. |
| 17 | // e.g. ".github/workflows/smoke-antigravity.lock.yml" → "smoke-antigravity" |
| 18 | func workflowIDFromPath(path string) string { |
| 19 | // Get the base filename |
| 20 | base := path |
| 21 | if idx := strings.LastIndex(path, "/"); idx >= 0 { |
| 22 | base = path[idx+1:] |
| 23 | } |
| 24 | // Strip .lock.yml suffix |
| 25 | base = strings.TrimSuffix(base, ".lock.yml") |
| 26 | // Strip .yml/.yaml suffix (in case it's not a lock file) |
| 27 | base = strings.TrimSuffix(base, ".yml") |
| 28 | base = strings.TrimSuffix(base, ".yaml") |
| 29 | return base |
| 30 | } |
| 31 | |
| 32 | // workflowIDFromRun returns the workflow ID preferring the path-derived ID, |
| 33 | // falling back to a lowercased/hyphenated version of the display name. |