Skip to content

Commit 9421e79

Browse files
committed
Add function workflows
1 parent 53e203c commit 9421e79

File tree

4 files changed

+143
-44
lines changed

4 files changed

+143
-44
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Function App Deploy Template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
environment:
7+
required: true
8+
type: string
9+
default: "dev"
10+
description: "Specifies the environment of the deployment."
11+
python_version:
12+
required: true
13+
type: string
14+
default: "3.10"
15+
description: "Specifies the python version."
16+
function_directory:
17+
required: true
18+
type: string
19+
description: "Specifies the directory of the Azure Function."
20+
function_name:
21+
required: true
22+
type: string
23+
description: "Specifies the name of the Azure Function."
24+
secrets:
25+
FUNCTION_PUBLISH_PROFILE:
26+
required: true
27+
description: "Specifies the publish profile of the function."
28+
29+
jobs:
30+
deployment:
31+
name: Function App Deploy
32+
runs-on: self-hosted
33+
continue-on-error: false
34+
environment: ${{ inputs.environment }}
35+
36+
steps:
37+
# Setup Python 3.10
38+
- name: Setup Python 3.10
39+
id: python_setup
40+
uses: actions/setup-python@v4
41+
with:
42+
python-version: ${{ inputs.python_version }}
43+
44+
# Check Out Repository
45+
- name: Check Out Repository
46+
id: checkout_repository
47+
uses: actions/checkout@v3
48+
49+
# Install Function Dependencies
50+
- name: Resolve Function Dependencies
51+
id: function_dependencies
52+
shell: bash
53+
run: |
54+
pushd '${{ inputs.function_directory }}'
55+
python -m pip install --upgrade pip
56+
pip install -r requirements.txt --target=".python_packages/lib/site-packages"
57+
popd
58+
59+
# Deploy Function
60+
- name: Deploy Function
61+
id: function_deploy
62+
uses: Azure/functions-action@v1
63+
with:
64+
app-name: ${{ inputs.function_name }}
65+
package: ${{ inputs.function_directory }}
66+
publish-profile: ${{ secrets.FUNCTION_PUBLISH_PROFILE }}
67+
scm-do-build-during-deployment: true
68+
enable-oryx-build: true
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Function App Test Template
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
python_version:
7+
required: true
8+
type: string
9+
default: "3.10"
10+
description: "Specifies the python version."
11+
function_directory:
12+
required: true
13+
type: string
14+
description: "Specifies the directory of the Azure Function."
15+
16+
jobs:
17+
deployment:
18+
name: Function App Test
19+
runs-on: ubuntu-latest
20+
continue-on-error: false
21+
22+
steps:
23+
# Setup Python 3.10
24+
- name: Setup Python 3.10
25+
id: python_setup
26+
uses: actions/setup-python@v4
27+
with:
28+
python-version: ${{ inputs.python_version }}
29+
30+
# Check Out Repository
31+
- name: Check Out Repository
32+
id: checkout_repository
33+
uses: actions/checkout@v3
34+
35+
# Run Python Tests
36+
- name: Run Python Tests
37+
id: python_test
38+
run: |
39+
pip install -r ${{ inputs.function_directory }}/requirements.txt -q
40+
pip install -r requirements.txt -q
41+
pytest

.github/workflows/functionApp.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Function App Deployment
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- "**.py"
8+
9+
pull_request:
10+
branches:
11+
- main
12+
paths:
13+
- "**.py"
14+
15+
jobs:
16+
function_test:
17+
uses: ./.github/workflows/_functionAppTestTemplate.yml
18+
name: "Function App Test"
19+
with:
20+
python_version: "3.10"
21+
function_directory: "./code/function"
22+
23+
function_deploy:
24+
uses: ./.github/workflows/_functionAppDeployTemplate.yml
25+
name: "Function App Deploy"
26+
needs: [function_test]
27+
if: github.event_name == 'push' || github.event_name == 'release'
28+
with:
29+
environment: "dev"
30+
python_version: "3.10"
31+
function_directory: "./code/function"
32+
function_name: "myfunc-dev-fctn001"
33+
secrets:
34+
FUNCTION_PUBLISH_PROFILE: ${{ secrets.FUNCTION_PUBLISH_PROFILE }}

.github/workflows/python.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)