GitHub Actions doesn't natively support dynamically populated dropdown options for workflow_dispatch inputs. This can become a maintenance headache, especially when managing multiple packages in an npm monorepo.
I came across a clever workaround shared by @jeevan-vj, demonstrating how to dynamically maintain dropdown options by automatically updating GitHub Actions workflow YAML files.
Inspired by that approach, I built a reusable GitHub Actions workflow that uses a dedicated WORKFLOW_TOKEN to update workflow files and automatically discover publishable packages in an npm monorepo.
Here's what my implementation adds:
✅ Automatic package discovery — Detects publishable npm workspace packages without maintaining a hardcoded list.
✅ Multi-workflow synchronization — Keeps package dropdown options consistent across multiple GitHub Actions workflows.
✅ YAML formatting preservation — Uses Python and ruamel.yaml to update workflow configurations while preserving their structure and formatting.
✅ Automatic and manual execution — Supports synchronization on push as well as manual triggering when needed.
✅ Configurable token authentication — Accepts a workflow-token secret, allowing each consuming repository to choose its own secret name.
✅ No unnecessary commits — Updates workflow files only when package options actually change.
🎯 The end result?
My release, publish, restore, reset, and release-draft workflows now automatically stay synchronized with the publishable packages in my npm monorepo.
No more manually updating package dropdowns every time a package is added, renamed, or removed.
Even better, the solution is reusable across repositories, so I have adopted the same automation in other repos without duplicating the synchronization logic.
🔗 Original inspiration — @jeevan-vj:
https://github.com/jeevan-vj/iamjeevan/blob/master/data/blog/dynamically-populating-parameter-options-in-manual-github-action.md
🔗 My reusable workflow implementation:
https://github.com/moyarich/reusable-workflows/blob/main/.github/workflows/reusable_sync-release-package-choices.yml
🔗 Real-world implementation — Workspace Tools:
https://github.com/moyarich/workspace-tools/blob/main/.github/workflows/sync-release-package-choices.yml
👏 Huge credit to @jeevan-vj for sharing the original workaround. It's a great example of how an open-source idea can evolve into a reusable solution that benefits other developers.
💬 How are you managing dynamic inputs in your GitHub Actions workflows? Have you found another approach?
Top comments (0)