Skip to content

chore: initial import #1

chore: initial import

chore: initial import #1

Workflow file for this run

# This workflow for our node.js 18 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@v2
- name: Use Node.js 18
uses: actions/setup-node@v2
with:
node-version: 18
- 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@v1
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 18
az webapp up --sku F1 --name nodejs-todo-sinedied --resource-group rg-copilot-nodejs-todo --runtime "node|18-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-sinedied --resource-group rg-copilot-nodejs-todo --settings COSMOS_ENDPOINT=$cosmos_endpoint COSMOS_KEY=$cosmos_key --output none