Skip to content

Commit 70eba44

Browse files
author
Gordon Byers
authored
Release Web App Automation (#232)
Adding manual release with Canary and Prod branch releases
1 parent 5a77537 commit 70eba44

File tree

1 file changed

+69
-6
lines changed

1 file changed

+69
-6
lines changed

.github/workflows/ghpages-release.yml

+69-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
type: string
99
required: true
1010
createRelease:
11-
description: 'Build the bicep and create a NEW GitHub release'
11+
description: 'Create a NEW release with that tag'
1212
type: boolean
1313
required: false
1414

@@ -18,9 +18,14 @@ env:
1818
jobs:
1919
BuildWebApp:
2020
runs-on: ubuntu-latest
21+
name: Build Web App
2122
steps:
2223
- uses: actions/checkout@v2
2324

25+
- name: Job Parameter Checking
26+
run: |
27+
echo "GitHub Ref: ${{ github.ref }}"
28+
2429
- name: Build node app with bicep release
2530
run: |
2631
cd helper
@@ -35,10 +40,25 @@ jobs:
3540

3641
CreateRelease:
3742
runs-on: ubuntu-latest
38-
if: ${{ github.event.inputs.createRelease }}
43+
name: Create GitHub Release (bicep)
44+
if: ${{ github.event.inputs.createRelease == 'true' }}
3945
steps:
4046
- uses: actions/checkout@v2
4147

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+
4262
- name: Install Bicep
4363
shell: pwsh
4464
run: az bicep install
@@ -65,21 +85,64 @@ jobs:
6585

6686
- name: Create GitHub release
6787
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 }}
6991

70-
DeployWebApp:
92+
DeployWebAppToCanary:
7193
runs-on: ubuntu-latest
94+
name: Deploy Web App to Canary Pages
95+
if: ${{ always() }}
7296
needs: [BuildWebApp , CreateRelease]
7397
steps:
7498
- uses: actions/download-artifact@v3
7599
with:
76100
name: WizardApp
77101
path: wizardapp
78102

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
80111
uses: crazy-max/ghaction-github-pages@v2
81112
with:
82-
target_branch: gh-pages-test
113+
target_branch: gh-pages-canary
114+
commit_message: Pages Release. Canary ${{env.templateRelease}}
83115
build_dir: wizardapp
116+
keep_history: true
84117
env:
85118
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

Comments
 (0)