-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (65 loc) · 2.48 KB
/
actions.yaml
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
name: github-actions
on:
pull_request:
branches:
- 'main'
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
AZURE_FUNCTIONAPP_NAME: ${{ secrets.AZURE_FUNCTIONAPP_NAME }}
AZURE_FUNCTIONAPP_PACKAGE_PATH: "function/"
NODE_VERSION: "20"
PYTHON_VERSION: "3.9"
jobs:
apply:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Initialize Terraform
run: terraform init
- name: Format
run: terraform fmt
- name: Validate
run: terraform validate
- name: Plan
if: github.event_name == 'pull_request'
run: terraform plan
- name: Apply
run: terraform apply -auto-approve
function:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get Publish Profile
id: get_publish_profile
uses: azure/CLI@v1
with:
inlineScript: |
az login --service-principal -u ${{ secrets.ARM_CLIENT_ID }} -p ${{ secrets.ARM_CLIENT_SECRET }} --tenant ${{ secrets.ARM_TENANT_ID }}
az account set --subscription ${{ secrets.ARM_SUBSCRIPTION_ID }}
PUBLISHPROFILE=$(az webapp deployment list-publishing-profiles --resource-group "rg-academy2024-anssihakanen" --name "fa-academyanssihakanen-dev-001" --xml)
echo "::add-mask::$PUBLISHPROFILE"
echo "publish_profile=$PUBLISHPROFILE" >> "$GITHUB_OUTPUT"
- name: Setup Python ${{ env.PYTHON_VERSION }} Environment
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: "Resolve Project Dependencies Using pip"
shell: bash
run: |
pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
pip install --upgrade pip
pip install --target=".python_packages/lib/site-packages" -r requirements.txt
popd
- name: "Run Azure Functions Action"
uses: Azure/[email protected]
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: ./${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ steps.get_publish_profile.outputs.publish_profile }}