name: Build, Push and Run Container on: [push] jobs: build-and-run: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: config-inline: | [registry."kode.sadateknologi.site"] http = false insecure = false # Login to Docker Hub for pulling base images (optional) - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} # Login to Gitea Registry - name: Login to Gitea Registry uses: docker/login-action@v3 with: registry: kode.sadateknologi.site username: ${{ gitea.repository_owner }} password: ${{ secrets.REGISTRY_TOKEN }} # Build and push image to Gitea Registry - name: Build and push uses: docker/build-push-action@v5 with: context: . push: true tags: | kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:${{ gitea.sha }} # Stop and remove existing container (if any) - name: Stop existing container run: | docker stop kulakpos_web || true docker rm kulakpos_web || true continue-on-error: true # Run the new container - name: Run container run: | docker run -d \ --name kulakpos_web \ --restart unless-stopped \ -p 8000:8000 \ -e PORT=8000 \ -e NODE_ENV=production \ kode.sadateknologi.site/${{ gitea.repository_owner }}/kulakpos_web:latest # Verify container is running - name: Verify container run: | sleep 5 docker ps | grep kulakpos_web curl -f http://localhost:8000/health || echo "Health check endpoint not configured"