feat: initial hello-world app with CI/CD pipeline
CI/CD Pipeline / lint-test (push) Failing after 2m5s
CI/CD Pipeline / build-push (push) Has been skipped
CI/CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
host-db
2026-06-20 11:57:31 +02:00
parent 8c9bfb64e8
commit 354e691ceb
5 changed files with 139 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
name: CI/CD Pipeline
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install deps
run: npm ci
- name: Lint
run: npm run lint
- name: Test
run: npm test
build-push:
needs: lint-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: registry.home:5000/admin/hello-world:${{ github.sha }},registry.home:5000/admin/hello-world:latest
deploy:
needs: build-push
runs-on: self-hosted
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy to VPS
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/deploy_key
chmod 600 ~/.ssh/deploy_key
ssh -i ~/.ssh/deploy_key -o StrictHostKeyChecking=accept-new root@100.89.217.78 << 'EOF'
mkdir -p /opt/stacks/hello-world
cd /opt/stacks/hello-world
docker compose -f docker-compose.prod.yml pull
docker compose -f docker-compose.prod.yml up -d
sleep 5
curl -f http://localhost:3000/health || docker compose -f docker-compose.prod.yml up -d --force-recreate
EOF
env:
TAG: ${{ github.sha }}