8
8
type : string
9
9
required : true
10
10
createRelease :
11
- description : ' Build the bicep and create a NEW GitHub release'
11
+ description : ' Create a NEW release with that tag '
12
12
type : boolean
13
13
required : false
14
14
18
18
jobs :
19
19
BuildWebApp :
20
20
runs-on : ubuntu-latest
21
+ name : Build Web App
21
22
steps :
22
23
- uses : actions/checkout@v2
23
24
25
+ - name : Job Parameter Checking
26
+ run : |
27
+ echo "GitHub Ref: ${{ github.ref }}"
28
+
24
29
- name : Build node app with bicep release
25
30
run : |
26
31
cd helper
@@ -35,10 +40,25 @@ jobs:
35
40
36
41
CreateRelease :
37
42
runs-on : ubuntu-latest
38
- if : ${{ github.event.inputs.createRelease }}
43
+ name : Create GitHub Release (bicep)
44
+ if : ${{ github.event.inputs.createRelease == 'true' }}
39
45
steps :
40
46
- uses : actions/checkout@v2
41
47
48
+ - name : Check that the GitHub release doesn't already exist
49
+ run : |
50
+ GHJSON=$(gh release view ${{env.templateRelease}} --json name) || GHJSON=""
51
+
52
+ if [ -z "$GHJSON" ]
53
+ then
54
+ echo "Release not found - great"
55
+ else
56
+ echo "Release already exists - aborting"
57
+ exit 1
58
+ fi
59
+ env :
60
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
61
+
42
62
- name : Install Bicep
43
63
shell : pwsh
44
64
run : az bicep install
@@ -65,21 +85,64 @@ jobs:
65
85
66
86
- name : Create GitHub release
67
87
run : |
68
- echo "TODO: Use GitHub CLI to create release"
88
+ GHJSON=$(gh release create ${{env.templateRelease}} 'bicep/compiled/main.json' -p --generate-notes )
89
+ env :
90
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
69
91
70
- DeployWebApp :
92
+ DeployWebAppToCanary :
71
93
runs-on : ubuntu-latest
94
+ name : Deploy Web App to Canary Pages
95
+ if : ${{ always() }}
72
96
needs : [BuildWebApp , CreateRelease]
73
97
steps :
74
98
- uses : actions/download-artifact@v3
75
99
with :
76
100
name : WizardApp
77
101
path : wizardapp
78
102
79
- - name : Deploy to GitHub Pages
103
+ # Although we don't need this artifact, if it's missing then we can abort this job
104
+ - uses : actions/download-artifact@v3
105
+ if : ${{ github.event.inputs.createRelease == 'true' }}
106
+ with :
107
+ name : CompiledBicep
108
+ path : compilebicep
109
+
110
+ - name : Deploy to GitHub Pages Canary
80
111
uses : crazy-max/ghaction-github-pages@v2
81
112
with :
82
- target_branch : gh-pages-test
113
+ target_branch : gh-pages-canary
114
+ commit_message : Pages Release. Canary ${{env.templateRelease}}
83
115
build_dir : wizardapp
116
+ keep_history : true
84
117
env :
85
118
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
119
+
120
+
121
+ DeployWebAppToProd :
122
+ runs-on : ubuntu-latest
123
+ name : Deploy Web App to Prod Pages
124
+ if : ${{ always() && github.ref == 'refs/heads/main'}}
125
+ environment : UI-Deploy-Manual-Approval
126
+ needs : [BuildWebApp , CreateRelease, DeployWebAppToCanary]
127
+ steps :
128
+ - uses : actions/download-artifact@v3
129
+ with :
130
+ name : WizardApp
131
+ path : wizardapp
132
+
133
+ # Although we don't need this artifact, if it's missing then we can abort this job
134
+ - uses : actions/download-artifact@v3
135
+ if : ${{ github.event.inputs.createRelease == 'true' }}
136
+ with :
137
+ name : CompiledBicep
138
+ path : compilebicep
139
+
140
+ - name : Deploy to GitHub Pages Prod
141
+ uses : crazy-max/ghaction-github-pages@v2
142
+ with :
143
+ target_branch : gh-pages
144
+ commit_message : Pages Release. Prod ${{env.templateRelease}}
145
+ build_dir : wizardapp
146
+ keep_history : true
147
+ env :
148
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments