I am creating a simple CD pipeline to deploy a Nest JS app on an Azure App Service.
I need generate prisma schema and also run prisma migrations after deployment is done.
When I try to run those with custom bash script, I get “Module not found” error”.
Seems like I’m not in the correct working directory. How can I run those scripts from my deployed app folder? The script should do something similar to “cd site/wwwroot && npx prisma generate” from kudo terminal.
I don’t want to put prisma commands in app service startup command since I don’t want to run then every time my web app restarts. I need to run them in my cd pipeline.
Here is a sample pipeline:
trigger:
- none
pool:
vmImage: ubuntu-latest
stages:
- stage: deploy_stage
displayName: 'Deploy Stage'
jobs:
- job: deploy_job
displayName: 'Deploy to Azure App Service'
steps:
- task: DownloadBuildArtifacts@1
inputs:
buildType: 'specific'
project: 'project-id'
pipeline: '6'
buildVersionToDownload: 'latest'
downloadType: 'single'
artifactName: 'artifact-name'
itemPattern: '**/artifact-name.zip'
downloadPath: '$(System.ArtifactsDirectory)'
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: 'azureSubscriptionId'
appType: 'webAppLinux'
WebAppName: 'my-web-app-name'
package: '$(System.ArtifactsDirectory)/path to artifact'
- script: 'node node_modules/prisma/build/index.js generate'
workingDirectory: $(System.DefaultWorkingDirectory)
displayName: 'Generate prisma types'
- script: 'node node_modules/prisma/build/index.js migrate deploy'
workingDirectory: $(System.DefaultWorkingDirectory)
displayName: 'Apply prisma migrations'
I tried different system variables to navigate to the correct directory, but couldn’t make it work.