Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
318 stars 53 forks source link

GitHub Action Deployment Successful, but functions not deploying #1497

Closed joewashek-dmi closed 1 week ago

joewashek-dmi commented 1 week ago

Short Description: Azure/static-web-apps-deploy@v1 GitHub Action appears to deploy successfully, but functions are not deployed. No Visible errors in logs.

I've been struggling with this for a few days. I have a React SWA with TypeScript functions (currently 9 API functions), and Postgres DB. Everything is working fine locally. I've then check-in code, do a pull-request, and the GitHub Action runs and completes successfully. The React site loads fine, and authentication is working, but all of the functions return 404. It seems they aren't deployed. In the VS Code Azure extension, when I expand the Function node for the SWA, it says no functions found.

My first thoughts were something with Prisma was failing, but Prisma seems fine. The build commands are completing, and the migration and seed commands are finishing successfully.

I've trying different things in the yaml and build scripts but can't find the problem. I'm thinking I may just start over with clean new application, and work by way back to this point.

Here's some important areas of the deployment logs showing success.

Using 'staticwebapp.config.json' file for configuration information, 'routes.json' will be ignored.
Copying 'staticwebapp.config.json' to build output
Try to validate location at: '/github/workspace/api'.
Api Directory Location: 'api' was found.
Starting to build function app with Oryx
Detecting platforms...
Detected following platforms:
  nodejs: 18.19.1
Version '18.19.1' of platform 'nodejs' is not installed. Generating script to install it...
Detected the following frameworks: Typescript

Source directory     : /github/workspace/api
Destination directory: /bin/staticsites/90bfb73e-36fe-41c6-86ad-15d568e49dec-swa-oryx/api

> api@1.0.0 prisma:generate
> prisma generate

Prisma schema loaded from prisma/schema.prisma

✔ Generated Prisma Client (v5.15.0) to ./node_modules/@prisma/client in 74ms
added 123 packages, and audited 124 packages in 13s

20 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "citus", schema "public" at "MASKING_THIS.postgres.cosmos.azure.com:5432"

5 migrations found in prisma/migrations

No pending migrations to apply.
Running seed command `ts-node prisma/seed.ts` ...

🌱  The seed command has been executed.
---End of Oryx build logs---
Function Runtime Information. OS: linux, Functions Runtime: ~4, node version: 18
Finished building function app with Oryx
Zipping Api Artifacts
Done Zipping Api Artifacts
Zipping App Artifacts
Done Zipping App Artifacts
Uploading build artifacts.
Finished Upload. Polling on deployment.
Status: InProgress. Time: 0.0604453(s)
Status: Succeeded. Time: 15.1214569(s)
Deployment Complete :)

Here's the VS Code extension show no functions have been uploaded (there should be 9 functions)

image

And here's the GitHub action

build_and_preview_job:
    if: github.event_name == 'pull_request' && github.event.action != 'closed'
    runs-on: ubuntu-latest
    name: Build and Deploy Preview Job
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: true
          lfs: false
      - name: Build And Deploy Preview
        id: builddeploypreview
        uses: Azure/static-web-apps-deploy@v1
        env:
          CI: false
          DATABASE_URL: ${{ secrets.POSTGRES_CONN_STAGING }}
          PRE_BUILD_COMMAND: "npm install -g prisma @prisma/client"
        with:
          azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_PEBBLE_0FAABC410 }}
          repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
          action: "upload"
          ###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
          # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
          app_location: "/" # App source code path
          api_location: "api" # Api source code path - optional
          output_location: "build" # Built app content directory - optional
          api_build_command: "npm run prisma:generate && npm run build"
          ###### End of Repository/Build Configurations ######
joewashek-dmi commented 1 week ago

This can be closed. The issue was some npm dev dependencies need to be move to regular dependencies.