This repository was archived by the owner on Jun 12, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathnode-app-deploy-pull-request.yml
More file actions
147 lines (143 loc) · 5.65 KB
/
Copy pathnode-app-deploy-pull-request.yml
File metadata and controls
147 lines (143 loc) · 5.65 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# This workflow will build and push a node.js application to an Azure Web App on every push to the master branch.
#
# To configure this workflow:
# 1. Set up a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE with the value of your Azure publish profile.
# 2. Change the value for AZURE_WEBAPP_NAME, AZURE_WEBAPP_PACKAGE_PATH and NODE_VERSION set as environment variables (below).
#
# For more information on GitHub Actions for Azure, refer to https://github.com/Azure/Actions
# For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples
on:
pull_request:
branches:
- master
paths-ignore:
- 'Policies/**'
env:
AZURE_RESOURCE_GROUP: gh-accelerator # set this to your Azure Resource group's name
AZURE_WEBAPP_NAME: node-gh-accelerator-pr # set this to your application's name
AZURE_WEBAPP_PACKAGE_PATH: "application" # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '10.x' # set this to the node version to use
jobs:
build:
name: Build and Test Node App
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
# Build and test the project
- name: npm install, build, and test
run: |
cd application
npm install
npm run build --if-present
npm run test --if-present
- name: Run unit tests
continue-on-error: false
run: |
cd tests
npm install
gulp unittest
- name: Creating artifact directories
run: |
mkdir buildartifacts
mkdir infrastructuretemplates
# Archive build artifact
- name: Archive Application
uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./buildartifacts/application.zip ./application
# Uploading application to build artifact
- name: Upload Application to Build Artifact
continue-on-error: false
uses: actions/upload-artifact@v2
with:
name: buildartifacts
path: buildartifacts
# Archive Arm templates
- name: Archive infrastructure ARM Templates
uses: montudor/action-zip@v0.1.0
with:
args: zip -qq -r ./infrastructuretemplates/infrastructure.zip ./infrastructure
# Uploading Arm Templates to artifacts
- name: Upload infrastructure ARM templates to Artifact
continue-on-error: false
uses: actions/upload-artifact@v2
with:
name: infrastructuretemplates
path: infrastructuretemplates
deploy:
name: Provision and Deploy to a review app
needs: build
runs-on: ubuntu-latest
steps:
# Downloading build artifact
- name: Download a Build Artifact
uses: actions/download-artifact@v2
continue-on-error: false
with:
name: buildartifacts
path: buildartifacts
# Uzipping build artifacts
- name: unzipping build artifact
uses: montudor/action-zip@v0.1.0
with:
args: unzip -qq ./buildartifacts/application.zip -d .
# Downloading Arm Templates
- name: Download infrastructure templates
uses: actions/download-artifact@v2
continue-on-error: false
with:
name: infrastructuretemplates
path: infrastructuretemplates
# Uzipping Arm template directory
- name: unzipping infrastructure artifact
uses: montudor/action-zip@v0.1.0
with:
args: unzip -qq ./infrastructuretemplates/infrastructure.zip -d .
# Deploy Arm template
- name: Login to Azure
uses: azure/login@v1
with:
creds: ${{secrets.AZURE_CREDENTIALS}}
- name: Provision a review web app
uses: azure/arm-deploy@v1
with:
# You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID, AZURE_RESOURCE_GROUP
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
resourceGroupName: ${{ env.AZURE_RESOURCE_GROUP }}
template: infrastructure/azuredeploy.json # Set this to the location of your template file
parameters: infrastructure/azuredeploy.parameters.json webappname=${{ env.AZURE_WEBAPP_NAME }} subscriptionId=${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Deploy Node app to Azure
- name: 'Deploy to Review WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
# Job to run functional tests
FunctionalTests:
name: Run Functional tests
runs-on: ubuntu-latest
needs: deploy
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
# Run functional tests
- name: set up test environment and run tests
continue-on-error: false
run: |
echo "Running functional tests"
# cd application
# npm install
# cd ../tests
# npm install
# $Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile $Path$Installer; Start-Process -FilePath $Path$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path$Installer
# Invoke-WebRequest https://chromedriver.storage.googleapis.com/83.0.4103.39/chromedriver_win32.zip -outFile chromedriver.zip
# Expand-Archive -Path chromedriver.zip
# Remove-Item chromedriver.zip
# gulp functionaltest --webAppUrl https://${{ env.AZURE_WEBAPP_NAME }}.azurewebsites.net/