-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Background
The .github/workflows/sync-to-nabledge.yml workflow contains large amounts of inline bash scripts embedded in the YAML file, making it difficult to maintain, test, and reuse.
Current State
The workflow already uses one external script (transform-to-plugin.sh), but several other steps still contain complex inline scripts:
- Validate version updates (lines 19-43) - Complex file change validation
- Clean nabledge repository (lines 54-57) - Repository cleanup
- Update CHANGELOG.md (lines 64-84) - Changelog manipulation with heredoc
- Validate marketplace structure (lines 86-126) - Extensive validation logic (40+ lines)
- Commit and Push to nabledge (lines 134-149) - Git operations
- Create and push version tag (lines 151-170) - Tag creation and version extraction
Proposed Changes
Extract inline scripts to .github/scripts/ directory:
| Script Name | Purpose | Current Lines |
|---|---|---|
validate-version-updates.sh |
Version validation logic | 19-43 |
clean-repository.sh |
Clean target repository | 54-57 |
update-changelog.sh |
Append sync entry to CHANGELOG | 64-84 |
validate-marketplace.sh |
Validate marketplace structure | 86-126 |
commit-and-push.sh |
Git commit and push operations | 134-149 |
create-version-tag.sh |
Create and push version tag | 151-170 |
Benefits
- Testability: Scripts can be tested locally without running the full workflow
- Reusability: Scripts can be reused across multiple workflows
- Maintainability: Easier to read, modify, and review
- Error handling: Better error handling and validation
- Consistency: Follow the pattern already established with
transform-to-plugin.sh
Implementation Guidelines
Each extracted script should:
- Include proper shebang (
#!/bin/bash) - Use error handling (
set -e,set -u,set -o pipefail) - Accept parameters via environment variables or arguments
- Include input validation
- Provide clear output messages
- Have execute permissions set in Git (
chmod +x)
Example structure:
#!/bin/bash
set -e
# Validate inputs
DEST_DIR="${1:-}"
if [ -z "$DEST_DIR" ]; then
echo "Error: Destination directory required"
exit 1
fi
# Use environment variables
echo "Processing version: $VERSION"
# Main logic
# ...
echo "Operation completed successfully"References
- Research documentation:
work/20260216/github-actions-external-scripts-guide.md - Existing example:
.github/scripts/transform-to-plugin.sh
Acceptance Criteria
- All 6 inline scripts extracted to
.github/scripts/directory - Scripts have execute permissions committed to Git
- Workflow YAML updated to call external scripts
- Scripts tested locally before committing
- Scripts follow best practices (error handling, validation, clear output)
- Workflow runs successfully after refactoring
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels