-
Notifications
You must be signed in to change notification settings - Fork 84
108 lines (94 loc) · 4.48 KB
/
test-workflow-node20-wcon.yaml
File metadata and controls
108 lines (94 loc) · 4.48 KB
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
name: Build on Windows and deploy Node.js project to Azure Function App using OIDC
# CONFIGURATION
#
# This workflow can be used to deploy your Node project to a function app on any hosting plan, except for Container Apps (which uses functions-container-action) and Flex Consumption (which uses `ubuntu-latest` as the runner).
#
# 1. Configure a federated identity credential to your GitHub branch on an Azure user-assigned managed identity.
# For instructions, follow the README at https://github.com/Azure/functions-action#use-oidc-recommended
#
# 2. Add the following values from the managed identity to your repo's variables:
# AZURE_CLIENT_ID
# AZURE_TENANT_ID
# AZURE_SUBSCRIPTION_ID
# For instructions on creating repo variables, see https://docs.github.com/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables#defining-configuration-variables-for-multiple-workflows
#
# 3. Ensure your workflow is triggered by your desired event. By default, it is triggered when a push is made to main, and it can be manually run.
# For guidance on event triggers, see https://docs.github.com/actions/writing-workflows/choosing-when-your-workflow-runs/triggering-a-workflow#using-events-to-trigger-workflows
#
# 4. Change the variables in the `env` section according to your project:
# For the latest list of supported runtimes, see https://learn.microsoft.com/azure/azure-functions/supported-languages
on:
push:
tags:
- 'v1'
# branches: [ main ]
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
env:
AZURE_FUNCTIONAPP_NAME: 'gae-fa-node20-wcon' # Set this to your function app name on Azure
AZURE_FUNCTIONAPP_PROJECT_PATH: './tests/e2e/node20' # Set this to the path to your function app project, defaults to the repository root. The deploy action will package the contents of this path.
NODE_VERSION: '20' # Set this to the Node version of your project
BUILD_ARTIFACT_NAME: 'released-package' # Set this according to your team's naming convention
jobs:
build:
runs-on: windows-latest # Assumes your target function app is Linux-based
permissions:
id-token: write # Required for OIDC
contents: read # Required for actions/checkout
defaults:
run:
shell: bash
working-directory: ${{ env.AZURE_FUNCTIONAPP_PROJECT_PATH }}
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
- name: 'Set up Node version: ${{ env.NODE_VERSION }}'
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Install project dependencies'
run: npm install # Use `npm ci` if you have a package-lock.json file and want to ensure a clean install
- name: 'Build project'
run: npm run build --if-present
- name: 'Run tests'
run: npm run test --if-present
- name: 'Prune development dependencies'
run: npm prune --production
- name: 'Upload artifact for the deployment job'
uses: actions/upload-artifact@v6
with:
name: ${{ env.BUILD_ARTIFACT_NAME }}
path: ${{ env.AZURE_FUNCTIONAPP_PROJECT_PATH }}
deploy:
runs-on: windows-latest # Assumes your target function app is Linux-based
needs: build
permissions:
id-token: write # Required for OIDC
steps:
- name: 'Download artifact from build job'
uses: actions/download-artifact@v4
with:
name: ${{ env.BUILD_ARTIFACT_NAME }}
path: '${{ env.AZURE_FUNCTIONAPP_PROJECT_PATH }}/downloaded-artifact'
- name: 'Log in to Azure with AZ CLI'
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID_FA_NODE20_WCON }}
tenant-id: ${{ secrets.AZURE_TENANT_ID_FA_E2E_TESTS }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID_FA_E2E_TESTS }}
- name: 'Run the Azure Functions action'
uses: Azure/functions-action@v1
id: deploy-to-function-app
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: '${{ env.AZURE_FUNCTIONAPP_PROJECT_PATH }}/downloaded-artifact'
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples