Merge pull request #60 from Ezeh20/real-time-order-chat #3
This file contains hidden or 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: Backend CI/CD | |
| on: | |
| pull_request: | |
| branches: [main] | |
| push: | |
| branches: [main] | |
| env: | |
| PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | |
| SERVICE_NAME: ikash-backend-dev | |
| REGION: us-central1 | |
| REPO_NAME: ikash-repo | |
| REGISTRY_URL: us-central1-docker.pkg.dev | |
| WIF_PROVIDER: ${{ vars.GCP_WIF_PROVIDER }} | |
| SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT_EMAIL }} | |
| jobs: | |
| test: | |
| name: Run tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - run: pnpm install --no-frozen-lockfile | |
| - run: pnpm run lint | |
| - run: pnpm run test | |
| deploy: | |
| name: Build & Deploy to Cloud Run | |
| needs: test | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Diagnose WIF configuration | |
| run: | | |
| echo "PROJECT_ID=${{ env.PROJECT_ID }}" | |
| echo "SERVICE_ACCOUNT=${{ env.SERVICE_ACCOUNT }}" | |
| echo "WIF_PROVIDER length: ${{ env.WIF_PROVIDER != '' && 'set' || 'EMPTY' }}" | |
| echo "WIF_PROVIDER format: $(echo '${{ env.WIF_PROVIDER }}' | grep -q '^projects/' && echo 'OK (projects/...)' || echo 'WARNING: should start with projects/')" | |
| echo "Repository: ${{ github.repository }}" | |
| - id: auth | |
| uses: google-github-actions/auth@v3 | |
| with: | |
| workload_identity_provider: ${{ env.WIF_PROVIDER }} | |
| service_account: ${{ env.SERVICE_ACCOUNT }} | |
| - uses: google-github-actions/setup-gcloud@v3 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| - uses: actions/setup-node@v5 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - run: pnpm install --no-frozen-lockfile | |
| - name: Authenticate Docker with Artifact Registry | |
| run: gcloud auth configure-docker ${{ env.REGISTRY_URL }} --quiet | |
| - name: Build Docker image | |
| run: | | |
| IMAGE="${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }}" | |
| docker build -t $IMAGE . | |
| docker tag $IMAGE "${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:latest" | |
| echo "image=$IMAGE" >> $GITHUB_ENV | |
| - name: Push Docker image | |
| run: | | |
| docker push "${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }}" | |
| docker push "${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:latest" | |
| - name: Deploy to Cloud Run | |
| run: | | |
| gcloud run deploy ${{ env.SERVICE_NAME }} \ | |
| --image "${{ env.REGISTRY_URL }}/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.SERVICE_NAME }}:${{ github.sha }}" \ | |
| --platform managed \ | |
| --region ${{ env.REGION }} \ | |
| --allow-unauthenticated \ | |
| --set-env-vars "DIDIT_API_URL=https://verification.didit.me/v3,STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org,STELLAR_NETWORK=testnet,TRUSTLESS_WORK_API_URL=https://dev.api.trustlesswork.com,TRUSTLESS_WORK_USDC_ISSUER=GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5,IKASH_PLATFORM_FEE=1,KYC_CALLBACK_URL=${{ vars.KYC_CALLBACK_URL }},STORAGE_PROVIDER=gcs,GCS_BUCKET_NAME=${{ secrets.GCS_BUCKET_NAME }},GCS_PROJECT_ID=${{ env.PROJECT_ID }},STORAGE_ENDPOINT=" \ | |
| --set-secrets "DIDIT_API_KEY=DIDIT_API_KEY:latest,DIDIT_WEBHOOK_SECRET=DIDIT_WEBHOOK_SECRET:latest,DIDIT_WORKFLOW_ID=DIDIT_WORKFLOW_ID:latest,STELLAR_SIGNER_SECRET=STELLAR_SIGNER_SECRET:latest,DATABASE_URL=DATABASE_URL:latest,DIRECT_URL=DIRECT_URL:latest,TRUSTLESS_WORK_API_KEY=TRUSTLESS_WORK_API_KEY:latest,IKASH_TREASURY_ADDRESS=IKASH_TREASURY_ADDRESS:latest,IKASH_SUPPORT_ADDRESS=IKASH_SUPPORT_ADDRESS:latest,IKASH_DEPLOYER_SECRET=IKASH_DEPLOYER_SECRET:latest" \ | |
| --service-account="${{ secrets.GCP_AUTH_SA }}" \ | |
| --timeout 300 \ | |
| --cpu 2 |