-
Notifications
You must be signed in to change notification settings - Fork 1
74 lines (72 loc) · 3.08 KB
/
deployment_per_branch.yml
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
name: .NET Framework Todo Demo App
on:
push:
branches:
- master
- staging
env:
OPSGENIE_ALIAS_BASE: "Rookout_TodoDemoDotNet-"
jobs:
build:
runs-on: windows-2019
steps:
- name: checkout
uses: actions/checkout@v1
- name: Setup Nuget.exe
with:
nuget-version: '5.x'
uses: nuget/setup-nuget@v1
- name: Restore
run: |
cd $Env:GITHUB_WORKSPACE
nuget restore
- name: Build and Deploy - Staging
if: github.ref == 'refs/heads/staging'
run: |
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe $Env:GITHUB_WORKSPACE /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=StagingDemoDeploymentProfile /p:Password=${{ secrets.REMOTE_IIS_STAGING_USER_PASSWORD }}
- name: Build and Deploy - Production
if: github.ref == 'refs/heads/master'
run: |
cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\"
.\MSBuild.exe $Env:GITHUB_WORKSPACE /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=DemoDeploymentProfile /p:Password=${{ secrets.REMOTE_IIS_USER_PASSWORD }}
- name: Open Opsgenie Alert
if: failure()
env:
OPSGENIE_API_KEY: ${{ secrets.OPSGENIE_API_KEY }}
run: |
$branchRef = $Env:GITHUB_REF
$branchRef = $branchRef.Split("/")[-1].Replace("/", "-").Replace("_", "-")
$opsgenieAlias = $Env:OPSGENIE_ALIAS_BASE + $branchRef
$paramsInJson =@{
"message" = $opsgenieAlias + " FAILURE"
"description" = "https://github.com/Rookout/TodoDemoDotNet/commit/" + $Env:GITHUB_SHA + "/checks?check_suite_id=" + $Env:GITHUB_ACTION
"alias" = $opsgenieAlias
"details" = @{
"status" = "FAILURE"
}
"entity" = "github-action"
"source" = "github-action"
"user" = "github"
} | ConvertTo-Json
$headers = @{
"Authorization" = "GenieKey " + $Env:OPSGENIE_API_KEY
}
Invoke-WebRequest -Uri https://api.opsgenie.com/v2/alerts -Method Post -ContentType "application/json" -Body $paramsInJson -Headers $headers
- name: Close Opsgenie Alert
if: success()
env:
OPSGENIE_API_KEY: ${{ secrets.OPSGENIE_API_KEY }}
run: |
$branchRef = $Env:GITHUB_REF
$branchRef = $branchRef.Split("/")[-1].Replace("/", "-").Replace("_", "-")
$opsgenieAlias = $Env:OPSGENIE_ALIAS_BASE + $branchRef
$paramsInJson =@{
"source" = "github-action"
"user" = "github"
} | ConvertTo-Json
$headers = @{
"Authorization" = "GenieKey " + $Env:OPSGENIE_API_KEY
}
$uri = "https://api.opsgenie.com/v2/alerts/" + $opsgenieAlias + "/close?identifierType=alias"
Invoke-WebRequest -Uri $uri -Method Post -ContentType "application/json" -Headers $headers -Body $paramsInJson