This repository contains example GitHub Actions workflows that build, publish and deploy Node.js services. Each workflow is designed to be re-used via workflow_call in other projects.
This workflow prepares the Node.js project, runs tests and builds a Docker image.
- Sets up the Node environment and caches dependencies
- Runs lint and tests (optionally publishing coverage)
- Publishes a release using semantic-release
- Builds a Docker image and uploads it as an artifact
- Outputs the service name so other workflows can use it
Loads the Docker image artifact produced by CI-BASE and pushes it to Amazon ECR.
- Configures AWS credentials and logs in to ECR
- Tags the image with the commit SHA and environment
- Optionally tags the pull request number
- Outputs the service name and image digest
Deploys the previously built image to Kubernetes.
- Checks out the
kubemanifests repository - Loads environment variables from AWS SSM
- Renders manifests with
envsubstand applies them withkubectl - Manages deployment metadata in
.deploys/service.json - Optionally comments on the pull request with the deployed image
Removes preview environments created for pull requests by deleting the Kubernetes namespace.
Promotes an image from one environment to another.
- Reads deployment metadata from
.deploys/service.jsonor a dev artifact - Updates the target environment entry and retags the image in ECR
- Pushes the updated metadata back to the
deploy-statebranch
Runs semantic-release on the main branch. It is mainly used locally to generate releases.
sequenceDiagram
participant Dev as Developer
participant CI_BASE as CI-BASE
participant CI_ECR as CI-ECR-BASE
participant Deploy as CI-K8-BASE
Dev->>CI_BASE: workflow_call
CI_BASE->>CI_ECR: upload image artifact
CI_ECR->>Deploy: push image & output digest
Deploy->>Kubernetes: apply manifests
flowchart TD
A[Deploy metadata] --> B[promote.yml]
B --> C{FROM_ENV}
C -->|dev| D[Download artifact]
C -->|stg/prod| E[Read .deploys/service.json]
D --> F[Update metadata for TO_ENV]
E --> F
F --> G[Retag image in ECR]
G --> H[Push deploy-state]
The ci_local.yml workflow is used only for running semantic-release locally.