forked from devkeydet/pva-alm
-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (101 loc) · 4.04 KB
/
build-deploy-solution.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
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
name: build-deploy-solution
# TODO: Makes sure this gets associated with the PR
on:
workflow_dispatch:
inputs:
ref:
required: true
description: "ref to build from"
sha:
required: false
description: "sha"
solution_name:
required: true
description: "solution to build"
environment:
required: true
description: "environment where the build will be deployed"
jobs:
build-deploy-solution:
runs-on: ubuntu-latest
name: deploy solution to ${{ github.event.inputs.environment }} environment
environment: ${{ github.event.inputs.environment }}
steps:
- if: contains(github.event.inputs.ref, 'refs/pull')
name: update-commit-status
id: update-commit-status
uses: actions/github-script@v5
env:
CONTEXT_TO_USE: build-deploy-${{ github.event.inputs.solution_name }}
SHA: ${{ github.event.inputs.sha }}
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
with:
script: |
console.log(process.env.CONTEXT_TO_USE)
console.log(process.env.SHA)
console.log(process.env.TARGET_URL)
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: process.env.SHA,
context: process.env.CONTEXT_TO_USE,
state: "pending",
target_url: process.env.TARGET_URL
})
- uses: actions/checkout@v2
- id: build-solution
uses: ./.github/actions/build-solution
with:
ref: ${{ github.event.inputs.ref }}
solution_name: ${{ github.event.inputs.solution_name }}
solution_package_source: "src/${{ github.event.inputs.solution_name }}/SolutionPackage"
- name: deploy-solution
uses: ./.github/actions/deploy-solution
with:
environment_url: ${{ secrets.ENVIRONMENT_URL }}
solution_name: ${{ github.event.inputs.solution_name }}
environment: ${{ needs.get-subdomain.outputs.subdomain }}
secrets: ${{ toJSON(secrets) }}
import-data-and-turn-on-flows:
runs-on: windows-2022
needs: build-deploy-solution
environment: ${{ github.event.inputs.environment }}
steps:
- uses: actions/checkout@v2
- id: import-configuration-migration-data-if-exists
uses: ./.github/actions/import-configuration-migration-data-if-exists
with:
environment_url: ${{ secrets.ENVIRONMENT_URL }}
solution_name: ${{ github.event.inputs.solution_name }}
tenant_id: ${{ secrets.TENANT_ID }}
app_id: ${{ secrets.CLIENT_ID }}
client_secret: ${{ secrets.CLIENT_SECRET }}
environment: ${{ github.event.inputs.environment }}
- id: turn-on-flows-impersonation
uses: ./.github/actions/turn-on-flows-impersonation
with:
environment_url: ${{ secrets.ENVIRONMENT_URL }}
solution_name: ${{ github.event.inputs.solution_name }}
tenant_id: ${{ secrets.TENANT_ID }}
app_id: ${{ secrets.CLIENT_ID }}
client_secret: ${{ secrets.CLIENT_SECRET }}
secrets: ${{ toJSON(secrets) }}
- if: contains(github.event.inputs.ref, 'refs/pull')
name: update-commit-status
id: update-commit-status
uses: actions/github-script@v5
env:
CONTEXT_TO_USE: build-deploy-${{ github.event.inputs.solution_name }}
SHA: ${{ github.event.inputs.sha }}
TARGET_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
JOB_STATUS: ${{ job.status }}
with:
script: |
await github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: process.env.SHA,
context: process.env.CONTEXT_TO_USE,
state: process.env.JOB_STATUS,
target_url: process.env.TARGET_URL
})