Azure Web App + Adonis

Perhaps it was just me, but it wasn't immediately obvious how to deploy TS apps to the Azure Web App service, using GitHub actions.
This process differs from the default JS starter that Azure sets up for you, as we need to include a build step, and deploy that folder - the process goes something like:
- Install all dependencies
- Run a build step
- Move to built folder, and install production-only dependencies
- Run startup script inside build folder
So setup GitHub deployment in the Azure portal (under Deployment Center), then edit the generated workflow:
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
name: Build and deploy Node.js app to Azure Web App
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Node.js version
uses: actions/setup-node@v1
with:
node-version: '14.x'
- name: Yarn install, build, and test
run: |
yarn install
yarn build
# Add the production dependencies step
- name: Yarn production
run: yarn install --production
working-directory: build # Install production dependencies in this folder
- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
with:
app-name: 'jammeryhq-api'
slot-name: 'production'
publish-profile: ${{ secrets.AzureAppService_PublishProfile }} # Generated by Azure
package: ./build # Change to your built folder with dependencies in
This assumes you have a package.json
(and a start
script) inside your build folder. This is the case with Adonis (v5) - it runs its build command, then copies package.json
into that folder.