Skip to content

Commit 04acc6b

Browse files
FestiveKylenektos/act
andauthored
Add maintenance page (canada-ca#4741)
* Add Tracker maintenance page * Revert changes to client.js * Update image policy tag * Update image tag * Add frontend-maintenance Image manifests to kustomization * Add patch to override frontend for maintenance page * Fix translation * Create set-maintenance.yml * Update set-maintenance.yml * Set maintenance page on for gke * Set maintenance page off for gke * Author commit using github.triggering_actor * Temporarily add push event * Remove push event * Change on_off variable name to onOff * Remove default values * Set options as strings * Set maintenance page on for gke * Set maintenance page off for gke * Fix cloudbuild entry directory --------- Co-authored-by: nektos/act <nektos/act@users.noreply.github.com> Co-authored-by: FestiveKyle <FestiveKyle@users.noreply.github.com>
1 parent c8b2371 commit 04acc6b

File tree

22 files changed

+915
-0
lines changed

22 files changed

+915
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Set/Remove Maintenance Page
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
deployment:
7+
# Which deployment to adjust maintenance page
8+
description: 'Which deployment to adjust'
9+
# Input has to be provided for the workflow to run
10+
required: true
11+
# The data type of the input
12+
type: choice
13+
options:
14+
- 'staging'
15+
- 'production'
16+
- 'gke'
17+
18+
onOff:
19+
# Turning the maintenance page on or off
20+
description: 'Turn the maintenance page on or off'
21+
# Input has to be provided for the workflow to run
22+
required: true
23+
# The data type of the input
24+
type: choice
25+
options:
26+
- 'on'
27+
- 'off'
28+
29+
jobs:
30+
update_value:
31+
# The type of runner that the job will run on
32+
runs-on: ubuntu-latest
33+
34+
permissions:
35+
# Give the default GITHUB_TOKEN write permission to commit and push the
36+
# added or changed files to the repository.
37+
contents: write
38+
39+
steps:
40+
- uses: actions/checkout@v3
41+
42+
- name: Update maintenance value
43+
run: |
44+
if [ "${{ inputs.onOff }}" == "on" ]; then PREFIX=""; else PREFIX="#"; fi
45+
sed -i "s/\s*#\{0,1\}\s*\(- \.\.\/\.\.\/bases\/frontend\/maintenance-override-component\)/${PREFIX} \1/g" k8s/apps/overlays/${{ inputs.deployment }}/kustomization.yaml
46+
47+
- uses: stefanzweifel/git-auto-commit-action@v4
48+
with:
49+
commit_message: Set maintenance page ${{ inputs.onOff }} for ${{ inputs.deployment }}
50+
commit_author: ${{ github.triggering_actor }} <${{ github.triggering_actor }}@users.noreply.github.com>
51+
file_pattern: 'k8s/apps/overlays/${{ inputs.deployment }}/kustomization.yaml'

frontend-maintenance/.dockerignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
cloudbuild.yaml
2+
Dockerfile
3+
LICENCE
4+
README.md
5+
.dockerignore

frontend-maintenance/Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM nginxinc/nginx-unprivileged:1.25-alpine3.17
2+
3+
RUN rm -rf /etc/nginx/html/*
4+
5+
COPY ./nginx.conf /etc/nginx/nginx.conf
6+
COPY ./html /usr/share/nginx/html
7+
8+
WORKDIR /app
9+
10+
EXPOSE 8080
11+
12+
CMD ["nginx-debug", "-g", "daemon off;"]

frontend-maintenance/LICENCE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Government of Canada - Gouvernement du Canada
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
steps:
2+
- name: 'gcr.io/cloud-builders/docker'
3+
id: generate-image-name
4+
entrypoint: 'bash'
5+
dir: frontend-maintenance
6+
args:
7+
- '-c'
8+
- |
9+
echo "gcr.io/$PROJECT_ID/frontend-maintenance:$BRANCH_NAME-$SHORT_SHA-$(date +%s)" > /workspace/imagename
10+
11+
- name: 'gcr.io/cloud-builders/docker'
12+
id: build-if-master
13+
entrypoint: 'bash'
14+
dir: frontend-maintenance
15+
args:
16+
- '-c'
17+
- |
18+
if [[ "$BRANCH_NAME" == "master" ]]
19+
then
20+
image=$(cat /workspace/imagename)
21+
docker build -t $image .
22+
else
23+
exit 0
24+
fi
25+
26+
- name: 'gcr.io/cloud-builders/docker'
27+
id: push-if-master
28+
entrypoint: 'bash'
29+
args:
30+
- '-c'
31+
- |
32+
if [[ "$BRANCH_NAME" == "master" ]]
33+
then
34+
image=$(cat /workspace/imagename)
35+
docker push $image
36+
else
37+
exit 0
38+
fi
39+
40+
timeout: 1200s
41+
options:
42+
machineType: 'E2_HIGHCPU_8'
Lines changed: 14 additions & 0 deletions
Loading

0 commit comments

Comments
 (0)