-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (109 loc) · 3.33 KB
/
deploy_to_azure.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI/CD
on:
push:
branches:
- main
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'
PYTHON_VERSION: '3.11'
STORAGE_ACCOUNT_NAME: 'hvalfangststorageaccount'
jobs:
build-function:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python version
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r hvalfangst_function/requirements.txt
- name: Zip artifact for deployment
run: cd hvalfangst_function && zip -r ../release.zip ./*
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: hvalfangst-function-app
path: |
release.zip
!venv/
deploy-function:
runs-on: ubuntu-latest
needs: build-function
environment:
name: 'Production'
url: ${{ steps.deploy-to-function.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v4
with:
name: hvalfangst-function-app
- name: Unzip artifact for deployment
run: unzip release.zip
- name: Deploy to Azure Functions
uses: Azure/functions-action@v1
id: deploy-to-function
with:
app-name: 'hvalfangstlinuxfunctionapp'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
scm-do-build-during-deployment: true
enable-oryx-build: true
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
build-react:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm install
working-directory: ./client
- name: Build React app
run: npm run build
working-directory: ./client
- name: Zip build folder
run: zip -r build.zip ./client/build
- name: Upload React build artifact
uses: actions/upload-artifact@v4
with:
name: react-build
path: build.zip
deploy-react:
runs-on: ubuntu-latest
needs: build-react
permissions:
id-token: write
contents: read
steps:
- name: Download React build artifact
uses: actions/download-artifact@v4
with:
name: react-build
- name: Unzip React build
run: unzip build.zip
- name: Login to Azure with OIDC
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 React build to Azure Static Website
uses: azure/CLI@v1
with:
azcliversion: latest
inlineScript: |
az storage blob upload-batch \
--account-name hvalfangststorageaccount \
--source ./client/build \
--destination '$web' \
--overwrite