|
1 | | -<!-- markdownlint-disable-next-line first-line-heading --> |
2 | | -<div align="center" width="100%"> |
| 1 | +# Continuous Integration - GitHub - Publish |
3 | 2 |
|
4 | | -# <img src=".github/logo.svg" width="60px" align="center" alt="logo" /> Continuous Integration - GitHub - Publish |
| 3 | +<div align="center"> |
| 4 | + <img src=".github/logo.svg" width="60px" align="center" alt="Logo for Continuous Integration - GitHub - Publish" /> |
| 5 | +</div> |
| 6 | + |
| 7 | +--- |
5 | 8 |
|
6 | 9 | [](https://github.com/hoverkraft-tech/ci-github-publish/actions/workflows/__main-ci.yml) |
7 | 10 | [](https://github.com/hoverkraft-tech/ci-github-publish/releases/) |
8 | 11 | [](#license) |
9 | 12 | [](CONTRIBUTING.md) |
10 | 13 |
|
11 | | -</div> |
| 14 | +## Overview |
12 | 15 |
|
13 | 16 | Opinionated GitHub Actions and workflows for streamlined release, deployment, and publishing. |
14 | 17 |
|
15 | | ---- |
16 | | - |
17 | 18 | ## Actions |
18 | 19 |
|
19 | 20 | ### ArgoCD |
@@ -112,6 +113,104 @@ _Reusable workflows for managing release process._ |
112 | 113 |
|
113 | 114 | 👍 If you wish to contribute to this project, please read the [CONTRIBUTING.md](CONTRIBUTING.md) file, PRs are Welcome ! |
114 | 115 |
|
| 116 | +### Action Structure Pattern |
| 117 | + |
| 118 | +All actions follow this consistent structure: |
| 119 | + |
| 120 | +```text |
| 121 | +actions/{category}/{action-name}/ |
| 122 | +├── action.yml # Action definition with inputs/outputs |
| 123 | +├── README.md # Usage documentation |
| 124 | +└── *.js # Optional Node.js scripts (e.g., prepare-site.js) |
| 125 | +``` |
| 126 | + |
| 127 | +### Development Standards |
| 128 | + |
| 129 | +#### Action Definition Standards |
| 130 | + |
| 131 | +1. **Consistent branding**: All actions use `author: hoverkraft`, `icon: <specific-icon>`, `color: blue` |
| 132 | +2. **Composite actions**: Use `using: "composite"` with GitHub Script for complex logic |
| 133 | +3. **Pinned dependencies**: Always pin action versions with SHA (e.g., `@ed597411d8f924073f98dfc5c65a23a2325f34cd`) |
| 134 | +4. **Input validation**: Validate inputs early in GitHub Script steps |
| 135 | + |
| 136 | +#### JavaScript Patterns |
| 137 | + |
| 138 | +- **Class-based architecture**: Use classes like `AssetManager` for complex functionality |
| 139 | +- **Path utilities**: Extensive use of Node.js `path` module for cross-platform compatibility |
| 140 | +- **Regular expression patterns**: Define constants for reusable patterns (`MARKDOWN_IMAGE_REGEX`, `HTML_IMAGE_REGEX`) |
| 141 | +- **Caching**: Implement Map-based caching for expensive operations |
| 142 | + |
| 143 | +### Development Workflow |
| 144 | + |
| 145 | +#### Linting & Testing |
| 146 | + |
| 147 | +```bash |
| 148 | +make lint # Run Super Linter (dockerized) |
| 149 | +make lint-fix # Auto-fix issues where possible |
| 150 | + |
| 151 | +# Use GitHub Actions locally with `act` |
| 152 | +gh act -W .github/workflows/workflow-file-to-test.yml |
| 153 | +``` |
| 154 | + |
| 155 | +#### File Conventions |
| 156 | + |
| 157 | +- **Dockerfile**: Uses Super Linter slim image for consistent code quality |
| 158 | +- **Tests**: Located in `tests/` with expected vs actual file comparisons |
| 159 | +- **Workflows**: Private workflows prefixed with `__` (e.g., `__main-ci.yml`) |
| 160 | + |
| 161 | +#### Action Development Conventions |
| 162 | + |
| 163 | +**Always follow these patterns when creating/modifying actions:** |
| 164 | + |
| 165 | +1. **Pinned Dependencies**: Use exact SHA commits for all action dependencies: |
| 166 | + |
| 167 | + ```yaml |
| 168 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 |
| 169 | + ``` |
| 170 | +
|
| 171 | +2. **Consistent Branding**: Every action.yml must include: |
| 172 | +
|
| 173 | + ```yaml |
| 174 | + author: hoverkraft |
| 175 | + branding: |
| 176 | + icon: <specific-icon> |
| 177 | + color: blue |
| 178 | + ``` |
| 179 | +
|
| 180 | +3. **Input Validation**: Always validate inputs early in GitHub Script steps: |
| 181 | + ```javascript |
| 182 | + const urlInput = ${{ toJson(inputs.url ) }}; |
| 183 | + if (!urlInput) { |
| 184 | + return core.setFailed("URL input is required."); |
| 185 | + } |
| 186 | + ``` |
| 187 | + |
| 188 | +#### JavaScript Development Patterns |
| 189 | + |
| 190 | +**For Node.js scripts (like `prepare-site.js`):** |
| 191 | + |
| 192 | +- Use class-based architecture for complex functionality |
| 193 | +- Define regex patterns as constants (`MARKDOWN_IMAGE_REGEX`, `HTML_IMAGE_REGEX`) |
| 194 | +- Implement Map-based caching for expensive operations |
| 195 | +- Always use Node.js `path` module for cross-platform compatibility |
| 196 | + |
| 197 | +#### File Structure Understanding |
| 198 | + |
| 199 | +```text |
| 200 | +actions/{category}/{action-name}/ # Modular action organization |
| 201 | +├── action.yml # Action definition with inputs/outputs |
| 202 | +├── README.md # Usage documentation |
| 203 | +└── *.js # Optional Node.js scripts |
| 204 | +
|
| 205 | +.github/workflows/ # Reusable workflows |
| 206 | +├── deploy-*.yml # Deployment orchestration |
| 207 | +├── clean-deploy-*.yml # Cleanup workflows |
| 208 | +└── __*.yml # Private/internal workflows |
| 209 | +
|
| 210 | +tests/ # Expected vs actual comparisons |
| 211 | +└── argocd-app-of-apps/ # Template testing structure |
| 212 | +``` |
| 213 | + |
115 | 214 | ## Author |
116 | 215 |
|
117 | 216 | 🏢 **Hoverkraft <contact@hoverkraft.cloud>** |
|
0 commit comments