Spaces:
Paused
Paused
ML Intern deploy
Deploy httpSMS gateway to Hugging Face Spaces (Docker SDK): nginx :7860 -> Go API :8000, Nuxt SPA, Android APK, bootstrap-mode entrypoint
83a59ca Download .github/workflows/api.yml from red-kit/httpsms-gateway: direct link, hf CLI and curl.
- Browser
- Download file 4.31 kB
-
https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/.github/workflows/api.yml
- Command line
-
hf download hf://spaces/red-kit/httpsms-gateway@6917738ca6db1603dee9e07994b4e42d5e1ae9b2/.github/workflows/api.yml
-
curl -L -o api.yml https://huggingface.co/spaces/red-kit/httpsms-gateway/resolve/6917738ca6db1603dee9e07994b4e42d5e1ae9b2/.github/workflows/api.yml
4.31 kB
| name: api | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| id-token: write | |
| jobs: | |
| test: | |
| name: Integration Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v7 | |
| - name: Set up Go | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: stable | |
| - name: Generate Firebase credentials | |
| run: | | |
| bash tests/generate-firebase-credentials.sh tests/firebase-credentials.json | |
| echo "FIREBASE_CREDENTIALS=$(jq -c . tests/firebase-credentials.json)" >> $GITHUB_ENV | |
| - name: Generate adapter certificates | |
| run: bash tests/generate-adapter-certificates.sh tests/certs | |
| - name: Start Services | |
| working-directory: ./tests | |
| run: docker compose up -d --build | |
| - name: Wait for services to be healthy | |
| working-directory: ./tests | |
| run: | | |
| echo "Waiting for MongoDB to be healthy..." | |
| for i in $(seq 1 20); do | |
| if docker compose exec mongodb mongosh --eval "db.runCommand('ping').ok" --quiet >/dev/null 2>&1; then | |
| echo "MongoDB is healthy!" | |
| break | |
| fi | |
| if [ $i -eq 20 ]; then | |
| echo "MongoDB failed to become healthy" | |
| docker compose logs mongodb | |
| exit 1 | |
| fi | |
| echo "MongoDB attempt $i/20 - waiting 3s..." | |
| sleep 3 | |
| done | |
| echo "Waiting for API to be healthy..." | |
| for i in $(seq 1 40); do | |
| if docker compose exec api curl -sf http://localhost:8000/health >/dev/null 2>&1; then | |
| echo "API is healthy!" | |
| break | |
| fi | |
| if [ $i -eq 40 ]; then | |
| echo "API failed to become healthy" | |
| docker compose logs api | |
| exit 1 | |
| fi | |
| echo "Attempt $i/40 - waiting 5s..." | |
| sleep 5 | |
| done | |
| - name: Seed Database | |
| working-directory: ./tests | |
| run: | | |
| echo "Waiting for seed container to finish..." | |
| docker compose wait seed || true | |
| sleep 2 | |
| - name: Run Handler Integration Tests | |
| working-directory: ./api | |
| env: | |
| USER_API_KEY: test-user-api-key | |
| run: go test -tags integration -v -timeout 60s ./pkg/handlers | |
| - name: Run Integration Tests | |
| working-directory: ./tests | |
| run: go test -v -timeout 300s ./... | |
| - name: Collect Logs on Failure | |
| if: failure() | |
| working-directory: ./tests | |
| run: | | |
| docker compose logs --tail 200 | |
| - name: Stop Services | |
| if: always() | |
| working-directory: ./tests | |
| run: docker compose down -v | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - name: Authenticate to Google Cloud | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }} | |
| service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
| - name: Set up Cloud SDK | |
| uses: google-github-actions/setup-gcloud@v3 | |
| - name: Trigger Cloud Build Deploy | |
| run: | | |
| BUILD_ID=$(gcloud builds triggers run api-httpsms-com \ | |
| --region=global \ | |
| --project=httpsms-86c51 \ | |
| --sha=${{ github.sha }} \ | |
| --format="value(metadata.build.id)") | |
| echo -e "Cloud Build: \033[34mhttps://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=httpsms-86c51\033[0m" | |
| echo "" | |
| echo "Polling Cloud Build Status..." | |
| while true; do | |
| STATUS=$(gcloud builds describe "$BUILD_ID" --region=global --project=httpsms-86c51 --format="value(status)") | |
| LOCAL_TIME=$(date -u '+%Y-%m-%d %H:%M:%S UTC') | |
| echo -e " \033[90m${LOCAL_TIME}\033[0m status=\033[36m${STATUS}\033[0m" | |
| case "$STATUS" in | |
| SUCCESS) echo -e "\033[32mBuild succeeded!\033[0m"; exit 0 ;; | |
| FAILURE|TIMEOUT|CANCELLED|EXPIRED|INTERNAL_ERROR) echo -e "\033[31mBuild failed with status: $STATUS\033[0m"; exit 1 ;; | |
| esac | |
| sleep 30 | |
| done | |