Skip to content

Commit 25319a6

Browse files
Create azure-deploy.yml
1 parent c667dce commit 25319a6

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

.github/workflows/azure-deploy.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
2+
# More GitHub Actions for Azure: https://github.com/Azure/actions
3+
4+
name: Build and deploy Node.js app to Azure Web App - streetsupport-platform-api
5+
6+
on:
7+
push:
8+
branches:
9+
- staging # Deploys to staging slot
10+
- main # Deploys to production slot
11+
12+
workflow_dispatch: # Allow manual trigger
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read #This is required for actions/checkout
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Set up Node.js version
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: '20.x'
27+
28+
- name: npm install, build, and test
29+
run: |
30+
npm install
31+
npm run build --if-present
32+
npm run test --if-present
33+
34+
- name: Upload artifact for deployment job
35+
uses: actions/upload-artifact@v4
36+
with:
37+
name: node-app
38+
path: .
39+
40+
deploy:
41+
runs-on: ubuntu-latest
42+
needs: build
43+
# Update to 'Production' || 'Staging' when configure additional environment
44+
environment: ${{ github.ref_name == 'main' && 'Staging' || 'Staging' }}
45+
permissions:
46+
id-token: write #This is required for requesting the JWT
47+
contents: read #This is required for actions/checkout
48+
49+
steps:
50+
- name: Download artifact from build job
51+
uses: actions/download-artifact@v4
52+
with:
53+
name: node-app
54+
55+
- name: Login to Azure
56+
uses: azure/login@v2
57+
with:
58+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
59+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
60+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
61+
62+
- name: 'Deploy to Azure Web App Slot'
63+
id: deploy-to-webapp
64+
uses: azure/webapps-deploy@v3
65+
with:
66+
# Current: Using slots in a single web app
67+
app-name: 'streetsupport-platform-api'
68+
# Update to 'Production' || 'Staging' when configure additional environment
69+
slot-name: ${{ github.ref_name == 'main' && 'Production' || 'Production' }}
70+
71+
# Alternative: For separate web apps (uncomment and modify as needed)
72+
# app-name: ${{ github.ref_name == 'main' && 'streetsupport-platform-api' || 'streetsupport-platform-api-staging' }}
73+
# Remove or comment out slot-name when using separate apps
74+
package: .

0 commit comments

Comments
 (0)