name: Build and Deploy Go App on: push: branches: - master - cicd - dev jobs: build: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 # Build backend - uses: actions/setup-go@v6 with: go-version: '^1.25' - name: Build backend run: | cd modules/backend go build -o nyanimedb . tar -czvf nyanimedb-backend.tar.gz nyanimedb - name: Upload built backend to artifactory uses: actions/upload-artifact@v3 with: name: nyanimedb-backend.tar.gz path: modules/backend/nyanimedb-backend.tar.gz - name: Build auth run: | cd modules/auth go build -o auth . tar -czvf nyanimedb-auth.tar.gz auth - name: Upload built auth to artifactory uses: actions/upload-artifact@v3 with: name: nyanimedb-auth.tar.gz path: modules/auth/nyanimedb-auth.tar.gz # Build frontend - uses: actions/setup-node@v5 with: node-version-file: modules/frontend/package.json cache: npm cache-dependency-path: modules/frontend/package-lock.json - name: Build frontend env: VITE_BACKEND_API_BASE_URL: ${{ vars.BACKEND_API_BASE_URL }} run: | cd modules/frontend npm install npm run build tar -czvf nyanimedb-frontend.tar.gz dist/ - name: Upload built frontend to artifactory uses: actions/upload-artifact@v3 with: name: nyanimedb-frontend.tar.gz path: modules/frontend/nyanimedb-frontend.tar.gz # Build Docker images - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: registry: ${{ vars.REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push backend image uses: docker/build-push-action@v6 with: context: . file: Dockerfiles/Dockerfile_backend push: true tags: meowgit.nekoea.red/nihonium/nyanimedb-backend:latest - name: Build and push auth image uses: docker/build-push-action@v6 with: context: . file: Dockerfiles/Dockerfile_auth push: true tags: meowgit.nekoea.red/nihonium/nyanimedb-auth:latest - name: Build and push frontend image uses: docker/build-push-action@v6 with: context: . file: Dockerfiles/Dockerfile_frontend push: true tags: meowgit.nekoea.red/nihonium/nyanimedb-frontend:latest deploy: runs-on: debian-test needs: build env: POSTGRES_USER: ${{ secrets.POSTGRES_USER }} POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} POSTGRES_DB: nyanimedb POSTGRES_PORT: 5432 POSTGRES_VERSION: 18 LOG_LEVEL: ${{ vars.LOG_LEVEL }} DATABASE_URL: ${{ secrets.DATABASE_URL }} SERVICE_ADDRESS: ${{ vars.SERVICE_ADDRESS }} RABBITMQ_URL: ${{ secrets.RABBITMQ_URL }} JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }} RABBITMQ_DEFAULT_USER: ${{ secrets.RABBITMQ_USER }} RABBITMQ_DEFAULT_PASS: ${{ secrets.RABBITMQ_PASSWORD }} steps: - name: Checkout code uses: actions/checkout@v4 - name: Deploy containers locally run: | cd deploy docker compose down || true docker compose pull || true docker compose up -d