improvements and fixes: update global styles, modify image sources in… #71
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Frontend Deploy Pipeline | |
on: | |
push: | |
branches: ['main'] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: [self-hosted, linux, x64, frontend] | |
timeout-minutes: 15 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Ensure buildx cache | |
run: mkdir -p /tmp/.buildx-cache | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Build and push Docker image | |
id: docker_build | |
run: | | |
for i in 1 2 3; do | |
if docker compose -f docker-compose.build.yml build && \ | |
docker compose -f docker-compose.build.yml push; then | |
exit 0 | |
fi | |
echo "Retry $i/3..." | |
sleep 10 | |
done | |
exit 1 | |
deploy: | |
needs: build | |
runs-on: [self-hosted, linux, x64, frontend] | |
environment: Production | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Deploy application | |
run: | | |
docker compose pull | |
docker compose up -d | |
- name: Deployment notification | |
run: echo "✅ Deployment completed" | |
health-check: | |
runs-on: [self-hosted, linux, x64, backend] | |
needs: deploy | |
timeout-minutes: 5 | |
steps: | |
- name: Health check with timeout and retry | |
run: | | |
max_attempts=12 | |
attempt=1 | |
while [ $attempt -le $max_attempts ]; do | |
if curl -sSf https://lab-spec.systems/api/health-check; then | |
echo "✅ Service is healthy!" | |
exit 0 | |
fi | |
echo "Attempt $attempt/$max_attempts - Service not healthy yet..." | |
sleep 15 | |
attempt=$((attempt + 1)) | |
done | |
echo "Health check failed after $max_attempts attempts" | |
exit 1 | |
- name: Final status | |
if: success() | |
run: echo "🚀 Application is running successfully in production" | |
cleanup: | |
runs-on: [self-hosted, linux, x64, frontend] | |
needs: health-check | |
if: always() | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Running cleanup script... | |
run: | | |
chmod +x ./.github/scripts/cleanup_system.sh | |
./.github/scripts/cleanup_system.sh |