-
Notifications
You must be signed in to change notification settings - Fork 12
50 lines (46 loc) · 2.14 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# This workflow for our node.js 20 app does the following:
# - run tests
# - build the app
# - login to Azure with AZURE_CREDENTIALS github secret
# - run Azure CLI command to deploy
name: Deploy to Azure
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build
run: npm run build
- name: Login to Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Deploy to Azure
run: |
# Create resource group rg-copilot-nodejs-todo
az group create --name rg-copilot-nodejs-todo --location eastus
# Create cosmosdb with default api
az cosmosdb create --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo
# Create database todos with collection tasks
az cosmosdb sql database create --account-name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --name todos
az cosmosdb sql container create --account-name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --database-name todos --name tasks --partition-key-path /_partitionKey --throughput 400
# Deploy webapp using node 20
az webapp up --sku F1 --name nodejs-todo-sinedied2 --resource-group rg-copilot-nodejs-todo --runtime "node|20-lts"
# Retrieve cosmos endpoint
cosmos_endpoint=$(az cosmosdb show --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --query documentEndpoint --output tsv)
# Retrieve cosmos key
cosmos_key=$(az cosmosdb keys list --name copilot-nodejs-todo --resource-group rg-copilot-nodejs-todo --query primaryMasterKey --output tsv)
# Set cosmos variables in web app
az webapp config appsettings set --name nodejs-todo-sinedied2 --resource-group rg-copilot-nodejs-todo --settings COSMOS_ENDPOINT=$cosmos_endpoint COSMOS_KEY=$cosmos_key --output none