-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or requestgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomers
Description
Description
The opencode-auth-sync plugin (https://github.com/activadee/opencode-auth-sync) enables automatic synchronization of OpenCode authentication from GitHub secrets, eliminating the need for a separate scheduled cache job. This refactoring simplifies the workflow setup and improves user experience by removing a required manual step.
Background
Currently, users opting for OAuth authentication must:
- Install the
opencode-auth.ymlworkflow - Manually run it to initialize the auth cache
- Rely on scheduled cache refresh (daily)
With opencode-auth-sync, the ~/.local/share/opencode/auth.json file is automatically synced from the OPENCODE_AUTH secret, removing operational overhead and the cache workflow entirely.
Goals
- Simplify workflow setup by eliminating cache dependencies
- Promote the
opencode-auth-syncplugin as the standard approach for OAuth users - Maintain backward compatibility with API key authentication
- Improve CLI user experience with plugin installation option
- Reduce maintenance burden of the cache job workflow
Technical Changes
1. Update Workflow Templates
src/cli/templates/shared.ts
- Remove or deprecate
CACHE_RESTORE_STEPconstant - Keep
ENV_OPENCODE_AUTHandENV_API_KEYas-is
src/cli/templates/pr-review.ts
- Remove conditional cache restore step
- Direct use of
OPENCODE_AUTHsecret without cache dependency - Remove import of
CACHE_RESTORE_STEP
src/cli/templates/issue-label.ts
- Remove conditional cache restore step
- Direct use of
OPENCODE_AUTHsecret without cache dependency - Remove import of
CACHE_RESTORE_STEP
src/cli/templates/doc-sync.ts
- Remove conditional cache restore step
- Direct use of
OPENCODE_AUTHsecret without cache dependency - Remove import of
CACHE_RESTORE_STEP
2. Update CLI Prompts and Flow
src/cli/index.ts
Changes:
- Remove automatic inclusion of
opencode-authworkflow when OAuth is selected - Add new prompt option: "Install opencode-auth-sync plugin? (recommended)" after OAuth selection
- Update next steps messaging for OAuth users:
- Add step to install the plugin:
bun install @activadee/opencode-auth-sync - Add step to configure the plugin in
.github/workflows/(if plugin provides setup automation) - Simplify secret setup: only requires
OPENCODE_AUTHsecret, no cache workflow - Remove instruction to manually run opencode-auth workflow
- Add step to install the plugin:
- Update help text (lines 27-57) to reflect that
opencode-auth.ymlis no longer required - Show different next steps based on plugin installation choice
src/cli/installer.ts
Changes:
- Keep
opencode-authinWORKFLOW_GENERATORSfor backward compatibility - Optional: Add silent skip logic if
opencode-authis somehow requested without OAuth
3. Preserve Backward Compatibility
- Users with existing
opencode-auth.ymlworkflows are unaffected - API key authentication flow remains unchanged
OPENCODE_AUTHsecret usage continues to work (plugin handles sync)
4. Documentation Updates
.github/workflows/opencode-auth.yml
- Optional deprecation notice in file (not removed, for backward compatibility)
- Consider moving to
docs/directory if users still reference it
README.md
- Remove or de-emphasize the
opencode-auth.ymlcache job workflow - Update authentication section to mention
opencode-auth-syncas primary approach for OAuth - Update quick start example to show plugin installation step (if automated by plugin)
Acceptance Criteria
- All imports of
CACHE_RESTORE_STEPremoved from template files (pr-review.ts,issue-label.ts,doc-sync.ts) - Generated workflow templates for OAuth users do NOT include cache restore steps
- CLI no longer automatically includes
opencode-auth.ymlwhen OAuth is selected - CLI prompts user for optional
opencode-auth-syncplugin installation - OAuth next steps messaging guides users to install the plugin instead of running manual cache workflow
- Help text (--help output) updated to remove reference to required
opencode-auth.ymlinstallation - API key authentication flow unchanged (still uses
ANTHROPIC_API_KEY) - All existing tests pass
- New tests cover:
- OAuth workflow generation without cache steps
- CLI prompt flow for plugin installation
- Next steps messaging for both plugin install and API key paths
- Backward compatibility verification (old secrets still work)
Implementation Notes
Workflow Generation Changes:
Before (OAuth):
- uses: actions/cache/restore@v4
with:
path: ~/.local/share/opencode/auth.json
key: opencode-auth-
- uses: activadee/open-workflows/actions/pr-review@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_AUTH: ${{ secrets.OPENCODE_AUTH }}After (OAuth with plugin):
- uses: activadee/open-workflows/actions/pr-review@main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OPENCODE_AUTH: ${{ secrets.OPENCODE_AUTH }}CLI Flow Updates:
- Multi-select workflows
- OAuth vs API key choice
- NEW: If OAuth selected, prompt: "Install opencode-auth-sync plugin?" (recommended)
- Check existing files + override confirmation
- Install workflows
- Show next steps (different for plugin vs no-plugin):
- With plugin: Install plugin, set OPENCODE_AUTH secret
- Without plugin: Set OPENCODE_AUTH secret, manually run opencode-auth workflow (backward compat message)
- API key: Set ANTHROPIC_API_KEY secret
Naming Conventions Followed:
- File naming: kebab-case (pr-review.ts, opencode-auth.ts) ✓
- Constants: SCREAMING_SNAKE_CASE ✓
- Functions: camelCase ✓
- Environment variables: SCREAMING_SNAKE_CASE ✓
Testing Strategy:
- Unit tests for template generation with/without cache steps
- Integration tests for CLI prompts and workflow installation
- Snapshot tests for generated workflow YAML
- E2E test verifying complete setup flow
References
- Repository: https://github.com/activadee/opencode-auth-sync
- Affected files:
src/cli/templates/,src/cli/index.ts,src/cli/installer.ts - Related workflows:
.github/workflows/opencode-auth.yml
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgithub_actionsPull requests that update GitHub Actions codePull requests that update GitHub Actions codegood first issueGood for newcomersGood for newcomers