This document outlines the best practices we implemented while creating the CODEANT QUALITY GATE SCAN GitHub Action.
- Clear naming: Used descriptive
nameanddescriptionfields - Author identification: Set proper
authorfield - Branding: Added
iconandcolorfor marketplace visibilitybranding: icon: "shield" color: "blue"
- Clear descriptions: Each input has a detailed description
- Required vs Optional: Properly marked required inputs
- Default values: Provided sensible defaults (e.g.,
api_base) - Documentation: Included examples in descriptions
Critical for composite actions: Always specify shell in run steps
- name: Step name
shell: bash
run: |
# commands here- Fail fast: Used
set -eto exit on any error - Explicit error messages: Added conditional checks with helpful error messages
if ! curl -fsSL ...; then echo "Error: Failed to fetch scan script" exit 1 fi
- Added echo statements to track progress
- Clear messages at each step for debugging
- Updated to
actions/checkout@v4(latest stable version) - Avoid using
@masteror@latestin production
- Used standard tools available in GitHub runners (curl, base64, bash)
- No need for additional setup steps
- Never hardcode tokens
- Use inputs with clear security requirements
- Document required permissions in README
- Validate downloaded scripts before execution
- Check curl exit codes
- Verify base64 decoding success
- Use
curl -fsSLflags:-f: Fail on HTTP errors-s: Silent mode-S: Show errors-L: Follow redirects
- Clear feature list
- Input/output documentation in table format
- Multiple usage examples (basic and advanced)
- Testing instructions before marketplace publication
- Required permissions documentation
- Publishing checklist
- Provided complete workflow examples
- Showed both simple and complex use cases
- Included testing from another repository instructions
codeant-quality-gates/
├── action.yml # Action definition
├── README.md # User documentation
├── README_LOCAL.md # Development documentation
└── LICENSE # License file (recommended)
- Removed boilerplate code (main.py)
- Keep only essential files
- Checkout: Get repository code
- Fetch: Download scan script
- Prepare: Decode and make executable
- Execute: Run the analysis
- Use descriptive names for each step
- Avoid generic names like "Run script"
-
Local testing: Test in another repository using branch reference
uses: username/repo@branch-name
-
Commit testing: Test specific commits
uses: username/repo@commit-sha
-
Tag testing: Create and test release tags
uses: username/repo@v1.0.0
- Test with minimal required inputs
- Test with all optional inputs
- Test error conditions (invalid tokens, unreachable API)
- Test on different runners (ubuntu, macos, windows if applicable)
- Add LICENSE file (required for marketplace)
- Create semantic version release (v1.0.0)
- Test thoroughly from another repository
- Verify branding displays correctly
- Ensure README has no placeholder text
- Add repository topics/tags
- Configure repository description
- Add GitHub repository metadata
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Create major version tags (v1) pointing to latest minor/patch
- Document breaking changes in release notes
Composite actions MUST specify shell for run steps
Always handle potential failures gracefully
Keep dependencies up-to-date (checkout@v4, not v2)
Users need to know what each input does and requires
Actions without branding are less discoverable in marketplace
Missing usage examples make actions hard to adopt
Users should know how to test before publishing
${{ github.repository }} # Current repository
${{ github.event.pull_request.head.sha }} # Pull request head commit SHA
${{ github.ref_name }} # Branch/tag name
${{ secrets.GITHUB_TOKEN }} # Auto-generated tokenenv:
API_BASE: ${{ inputs.api_base }}${{ inputs.access_token }}
${{ inputs.api_base }}- Single API call to fetch script
- No unnecessary downloads or processing
- Uses default checkout settings (fast)
- Only checks out when needed
- Self-documenting step names
- Informative echo messages
- Proper git usage
- Clean commit history
- Semantic versioning for releases
- Both user-facing (README.md) and developer-facing (README_LOCAL.md)
- Inline documentation in action.yml
This action follows GitHub's official best practices for:
- Composite action structure
- Security and token handling
- Error handling and logging
- Documentation and examples
- Testing and marketplace publication
Following these practices ensures a reliable, secure, and maintainable GitHub Action that users can trust and easily integrate into their workflows.