feat: initial health-app with Express API and GitOps CI/CD
Node.js Express app with /health, /ready, / endpoints. Multi-stage Dockerfile, GitHub Actions pipeline for GHCR push and gitops-infra manifest auto-update. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
83
.github/workflows/ci-cd.yaml
vendored
Normal file
83
.github/workflows/ci-cd.yaml
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
name: CI/CD - Build, Push & Deploy
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "src/**"
|
||||
- "Dockerfile"
|
||||
- "package.json"
|
||||
- "package-lock.json"
|
||||
- ".github/workflows/ci-cd.yaml"
|
||||
|
||||
env:
|
||||
REGISTRY: ghcr.io
|
||||
IMAGE_NAME: ${{ github.repository_owner }}/health-app
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
name: Build & Push Docker Image
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
short_sha: ${{ steps.sha.outputs.short }}
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get short SHA
|
||||
id: sha
|
||||
run: echo "short=$(echo ${{ github.sha }} | cut -c1-7)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build and push Docker image
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.sha.outputs.short }}
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
update-manifest:
|
||||
name: Update GitOps Manifest
|
||||
needs: build-and-push
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout gitops-infra repo
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
repository: infinicaretech/gitops-infra
|
||||
token: ${{ secrets.GITOPS_PAT }}
|
||||
|
||||
- name: Update image tag in kustomization
|
||||
run: |
|
||||
cd environments/health-app/overlays/production
|
||||
sed -i "s/newTag: .*/newTag: ${{ needs.build-and-push.outputs.short_sha }}/" kustomization.yaml
|
||||
echo "Updated image tag to: ${{ needs.build-and-push.outputs.short_sha }}"
|
||||
cat kustomization.yaml
|
||||
|
||||
- name: Commit and push
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add environments/health-app/overlays/production/kustomization.yaml
|
||||
git diff --cached --quiet && echo "No changes to commit" && exit 0
|
||||
git commit -m "chore(health-app): update image to ${{ needs.build-and-push.outputs.short_sha }}"
|
||||
git push
|
||||
Reference in New Issue
Block a user