Skip to content

Merge pull request #53 from StreetSupport/feature/merge_staging_into_… #56

Merge pull request #53 from StreetSupport/feature/merge_staging_into_…

Merge pull request #53 from StreetSupport/feature/merge_staging_into_… #56

Workflow file for this run

# 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 - streetsupport-platform-api
on:
push:
branches:
- staging # Deploys to staging slot
- main # Deploys to production slot
workflow_dispatch: # Allow manual trigger
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
SENTRY_ENV: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
steps:
- uses: actions/checkout@v4
- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '24.x'
- name: Setup Sentry
run: |
npm install -g @sentry/cli
sentry-cli --auth-token $SENTRY_AUTH_TOKEN info
- name: npm install, lint, build, and test
run: |
npm install
npm run lint
npm run build --if-present
npm run test --if-present
- name: Clean build artifacts and dependencies
run: rm -rf dist node_modules
- name: Zip artifact for deployment
run: zip -r release.zip .
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: release.zip
deploy:
runs-on: ubuntu-latest
needs: build
environment: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
permissions:
id-token: write
contents: read
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: node-app
- name: Login to Azure
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: 'Deploy to Azure Web App'
id: deploy-to-webapp
uses: azure/webapps-deploy@v3
with:
app-name: ${{ vars.AZURE_APP_NAME }}
# To think about reverting this part
package: release.zip
startup-command: 'npm start'
clean: true