You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- `needs: [lint, verify-typescript-types, code-coverage]`: This ensures the job only runs after the previous jobs have completed successfully, creating a pipeline.
285
+
286
+
- `permissions`: Explicitly sets the required permissions for the GITHUB_TOKEN to read repository contents and write to the GitHub Packages registry.
287
+
288
+
- `docker/setup-buildx-action@v3`: Sets up Docker Buildx, which provides enhanced build capabilities including better caching and multi-platform builds.
289
+
290
+
- `docker/login-action@v3`: Authenticates with GitHub Container Registry using the automatically provided GITHUB_TOKEN.
291
+
292
+
- `docker/metadata-action@v5`: Extracts metadata from Git to create appropriate tags and labels for the Docker image:
293
+
294
+
- `type=ref,event=branch`: Tags the image with the branch name (e.g., `main`)
295
+
- `type=sha,format=short`: Tags the image with the short Git commit SHA for easier identification
296
+
297
+
- `docker/build-push-action@v5`: Builds and pushes the Docker image with:
298
+
- Multi-platform support for both AMD64 (standard x86 processors) and ARM64 (like Apple Silicon)
299
+
- GitHub Actions cache integration for faster builds
300
+
- Tags and labels from the metadata action
301
+
- Automatic push to the registry
302
+
303
+
#### What you've learned:
304
+
305
+
**Skills acquired:**
306
+
307
+
- 🔄 **CI/CD Pipeline Construction**: You've created a complete pipeline from code quality checks to deployment, learning how jobs can depend on each other with the `needs` keyword.
308
+
- 🐳 **Docker Integration**: You've learned how to build and push multi-architecture Docker images (AMD64 and ARM64) as part of your CI/CD pipeline.
309
+
- 🔑 **Secure Authentication**: You've used GitHub's built-in token system to securely authenticate with the container registry without exposing credentials.
310
+
- 🏷️ **Image Tagging Strategies**: You've implemented best practices for versioning container images using Git metadata.
311
+
- 🚀 **Deployment Automation**: You've automated the deployment process, ensuring that only code that passes quality checks gets deployed.
312
+
313
+
**Why it matters:**
314
+
315
+
Containerization is a critical part of modern application deployment. By automating the build and push process, you ensure consistent, reproducible deployments and eliminate manual steps that could introduce errors. This completes the CI/CD pipeline, taking your code from commit to deployable artifact.
316
+
317
+
**Using your container image:**
318
+
319
+
Once pushed, your image will be available at `ghcr.io/ekino/githubworkflow-handson-nodejs` with two tags:
320
+
321
+
- Branch name tag: `ghcr.io/ekino/githubworkflow-handson-nodejs:main`(or your branch name)
322
+
- Short SHA tag: `ghcr.io/ekino/githubworkflow-handson-nodejs:a1b2c3d`(abbreviated commit hash)
The multi-architecture support means the same image works on both Intel/AMD machines and ARM-based systems like Apple Silicon Macs.
335
+
336
+
</details>
337
+
223
338
### Conclusion:
224
339
225
340
<details>
226
341
<summary>Expand</summary>
227
342
228
-
With these three jobs, you’ve built a basic **quality pipeline** for any Node.js project:
343
+
With these four jobs, you've built a complete **CI/CD pipeline** for any Node.js project:
229
344
230
345
- **Linting** ensures a clean codebase.
231
346
- **Typing** ensures static correctness.
232
347
- **Testing & Coverage** ensure reliability and confidence.
348
+
- **Docker Build & Push** automates deployment and ensures only quality code is deployed.
233
349
234
-
You now know how to set up **automated checks on every push or pull request**, forming the foundation of a **collaborative development workflow**.
350
+
You now know how to set up **automated checks on every push or pull request**, forming the foundation of a **collaborative development workflow** that extends all the way to deployment.
0 commit comments