Skip to content

Commit 5eace45

Browse files
author
hvalfangst
committed
Implemented CI/CD pipeline for automatic deployments to Azure on repo push
1 parent 48f909c commit 5eace45

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: CI/CD
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
env:
10+
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'
11+
PYTHON_VERSION: '3.10'
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Python version
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ env.PYTHON_VERSION }}
24+
25+
- name: Create and start virtual environment
26+
run: |
27+
python -m venv venv
28+
source venv/bin/activate
29+
30+
- name: Install dependencies
31+
run: pip install -r requirements.txt
32+
33+
- name: Zip artifact for deployment
34+
run: zip -r release.zip host.json requirements.txt function_app.py
35+
36+
- name: Upload artifact for deployment job
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: python-app
40+
path: |
41+
release.zip
42+
!venv/
43+
44+
deploy:
45+
runs-on: ubuntu-latest
46+
needs: build
47+
environment:
48+
name: 'Production'
49+
url: ${{ steps.deploy-to-function.outputs.webapp-url }}
50+
51+
steps:
52+
- name: Download artifact from build job
53+
uses: actions/download-artifact@v3
54+
with:
55+
name: python-app
56+
57+
- name: Unzip artifact for deployment
58+
run: unzip release.zip
59+
60+
- name: 'Deploy to Azure Functions'
61+
uses: Azure/functions-action@v1
62+
id: deploy-to-function
63+
with:
64+
app-name: 'hvalfangstlinuxfunctionapp'
65+
slot-name: 'Production'
66+
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
67+
scm-do-build-during-deployment: true
68+
enable-oryx-build: true
69+
publish-profile: ${{ secrets.PUBLISH_PROFILE }}

0 commit comments

Comments
 (0)