Skip to content

Commit c6c2d4c

Browse files
committed
feat: Modernize deployment and configuration system
Major updates: - Analytics telemetry integration with penguin-analytics - Reactive configuration system using Angular signals - Multi-stage Dockerfile for consistent deployments - Simplified GitHub Actions workflows Configuration System: - New env.js pattern with configEndpoint flag - ConfigService with signal-based reactivity - Dynamic banner and environment display - Local dev uses proxy, deployed uses /api/config - All services (analytics, auth, API) use config() signal Deployment Modernization: - Multi-stage Dockerfile (Node 22 + nginx 1.27) - Embedded nginx config (no OpenShift base image dependency) - Simplified workflows: checkout, login, build/push - Removed Helm complexity for test/prod deploys - Consistent with eagle-public deployment pattern nginx Configuration: - Alias /tmp/app/dist/ to handle /admin/* prefix from rproxy - Analytics proxy removed (use direct penguin-analytics URL) - CSP allows Material Icons, BC Gov scripts, Typekit - Health check endpoint at /health Developer Experience: - Local development with configEndpoint=false - Deployed environments fetch config from API - Proxy configuration for local API/analytics - Comprehensive architecture and deployment docs Testing: - 43 unit tests passing - Lint clean - Workflows validated This represents a complete modernization matching eagle-public's deployment architecture and configuration management.
1 parent 58e3520 commit c6c2d4c

31 files changed

+2045
-363
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# These owners will be the default owners for everything in
22
# the repo. Unless a later match takes precedence,
33
# they will be requested for review when someone opens a pull request.
4-
* @marklise @tom0827 @Ckoelewyn @tolkamps1 @danieltruong
4+
* @tom0827 @Ckoelewyn @tolkamps1 @danieltruong

.github/workflows/deploy-to-dev.yaml

Lines changed: 20 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to Dev
1+
name: CI - Build and Deploy to Dev
22

33
on:
44
push:
@@ -19,63 +19,17 @@ env:
1919

2020
jobs:
2121
build:
22-
name: Build
22+
name: Build and Push Image
2323
runs-on: ubuntu-latest
24-
strategy:
25-
matrix:
26-
node-version: [22.x]
2724
outputs:
2825
SHORT_SHA: ${{ steps.short-sha.outputs.SHA }}
2926
steps:
3027
- name: Checkout repository
3128
uses: actions/checkout@v4
32-
with:
33-
fetch-depth: 2 # Need at least 2 commits to compare changes
34-
35-
- name: Enable Corepack
36-
run: corepack enable
37-
38-
- name: Use Node.js 22
39-
uses: actions/setup-node@v4
40-
with:
41-
node-version: ${{ matrix.node-version }}
42-
cache: "yarn"
43-
- run: yarn install --immutable
44-
45-
- name: Angular Build
46-
run: yarn build
47-
48-
- name: Install OpenShift CLI
49-
run: |
50-
curl -LO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz"
51-
tar -xvzf openshift-client-linux.tar.gz
52-
sudo mv oc /usr/local/bin/
53-
rm -f openshift-client-linux.tar.gz
54-
55-
- name: Log into OpenShift
56-
uses: redhat-actions/oc-login@v1
57-
with:
58-
openshift_server_url: ${{ secrets.OPENSHIFT_URL }}
59-
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
60-
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
61-
62-
- name: Check if nginx config changed
63-
id: nginx-check
64-
run: |
65-
# Check if nginx-runtime config files changed in this commit
66-
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -q "openshift/templates/nginx-runtime/"; then
67-
echo "Nginx config files changed"
68-
echo "changed=true" >> $GITHUB_OUTPUT
69-
else
70-
echo "No nginx config changes detected"
71-
echo "changed=false" >> $GITHUB_OUTPUT
72-
fi
7329

74-
- name: Rebuild nginx-runtime image
75-
if: steps.nginx-check.outputs.changed == 'true'
76-
run: |
77-
echo "Nginx config changed, rebuilding nginx-runtime image..."
78-
oc start-build eagle-admin-nginx-runtime -n ${{ env.OPENSHIFT_NAMESPACE }} --wait --follow
30+
- name: Get Short SHA
31+
id: short-sha
32+
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
7933

8034
- name: Login to OpenShift registry
8135
uses: docker/login-action@v3
@@ -84,17 +38,15 @@ jobs:
8438
username: ${{ secrets.OPENSHIFT_REPOSITORY_USERNAME }}
8539
password: ${{ secrets.OPENSHIFT_REPOSITORY_PASSWORD }}
8640

87-
- name: Get Short SHA
88-
id: short-sha
89-
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
90-
9141
- name: Build and push Docker image
9242
uses: docker/build-push-action@v6
9343
with:
9444
context: .
9545
push: true
96-
tags: ${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:ci-latest
97-
file: Dockerfile.Github
46+
tags: |
47+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:dev
48+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:ci-latest
49+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.SHA }}
9850
labels: |
9951
commit.author=${{ github.event.head_commit.author.email }}
10052
commit.id=${{ github.event.head_commit.id }}
@@ -115,6 +67,7 @@ jobs:
11567
with:
11668
ref: "${{ env.TEST_PROMO_BRANCH }}"
11769
- name: Update state.json
70+
id: update-state
11871
run: |
11972
git config --global user.name "${{ github.actor }}"
12073
git config --global user.email "${{github.actor}}@users.noreply.github.com"
@@ -124,9 +77,17 @@ jobs:
12477
12578
echo $(jq '.commit="${{ needs.build.outputs.SHORT_SHA }}"' state.json) > state.json
12679
127-
git commit -am "Promote commit ${{ needs.build.outputs.SHORT_SHA }} to Test"
128-
git push --force origin ${{ env.TEST_PROMO_PR_BRANCH }}
80+
# Only commit if there are changes
81+
if git diff --quiet state.json; then
82+
echo "No changes to state.json, skipping commit"
83+
echo "has_changes=false" >> $GITHUB_OUTPUT
84+
else
85+
git commit -am "Promote commit ${{ needs.build.outputs.SHORT_SHA }} to Test"
86+
git push --force origin ${{ env.TEST_PROMO_PR_BRANCH }}
87+
echo "has_changes=true" >> $GITHUB_OUTPUT
88+
fi
12989
- name: Create or Update Pull Request
90+
if: steps.update-state.outputs.has_changes == 'true'
13091
run: |
13192
# Check if PR exists
13293
PR_URL=$(gh pr list --base "${{ env.TEST_PROMO_BRANCH }}" --head "${{ env.TEST_PROMO_PR_BRANCH }}" --json url --jq '.[0].url')
Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
name: Deploy to Prod
22

33
on:
4-
repository_dispatch:
5-
# Trigger from repository dispatch workflow in promotion/prod branch
6-
types: [trigger-prod-deploy]
4+
workflow_dispatch:
75

86
permissions: write-all
97

@@ -12,50 +10,32 @@ env:
1210
IMAGE_NAME: eagle-admin
1311

1412
jobs:
15-
deploy:
16-
name: Deploy to Prod
13+
build:
14+
name: Build and Push Image
1715
runs-on: ubuntu-latest
18-
outputs:
19-
COMMIT_SHA: ${{ steps.read-hash.outputs.SHA }}
2016
steps:
2117
- name: Checkout repository
22-
uses: actions/checkout@v3
23-
with:
24-
ref: "promotion/prod"
25-
26-
- name: Retrieve previous commit hash
27-
id: read-hash
28-
run: echo "SHA=$(jq -r '.commit' state.json)" >> $GITHUB_OUTPUT
18+
uses: actions/checkout@v4
2919

30-
- name: Install OpenShift CLI
31-
run: |
32-
curl -LO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz"
33-
tar -xvzf openshift-client-linux.tar.gz
34-
sudo mv oc /usr/local/bin/
35-
rm -f openshift-client-linux.tar.gz
20+
- name: Get Short SHA
21+
id: short-sha
22+
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
3623

37-
- name: Log into OpenShift
38-
uses: redhat-actions/oc-login@v1
24+
- name: Login to OpenShift registry
25+
uses: docker/login-action@v3
3926
with:
40-
openshift_server_url: ${{ secrets.OPENSHIFT_URL }}
41-
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
42-
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
43-
44-
- name: Tag image
45-
run: |
46-
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:prod ${{ env.IMAGE_NAME }}:prod-backup
47-
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:test ${{ env.IMAGE_NAME }}:prod
27+
registry: ${{ secrets.OPENSHIFT_REPOSITORY }}
28+
username: ${{ secrets.OPENSHIFT_REPOSITORY_USERNAME }}
29+
password: ${{ secrets.OPENSHIFT_REPOSITORY_PASSWORD }}
4830

49-
sync-main-branch:
50-
name: Rebase Prod
51-
needs: deploy
52-
runs-on: ubuntu-latest
53-
steps:
54-
- name: Checkout repository
55-
uses: actions/checkout@v3
31+
- name: Build and push Docker image
32+
uses: docker/build-push-action@v6
5633
with:
57-
ref: "main"
58-
- run: |
59-
git fetch origin test
60-
git rebase ${{needs.deploy.outputs.COMMIT_SHA}} main
61-
git push origin main
34+
context: .
35+
push: true
36+
tags: |
37+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:prod
38+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.SHA }}
39+
labels: |
40+
commit.id=${{ github.sha }}
41+
commit.timestamp=${{ github.event.head_commit.timestamp }}
Lines changed: 22 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,41 @@
11
name: Deploy to Test
22

33
on:
4-
repository_dispatch:
5-
# Trigger from repository dispatch workflow in promotion/test branch
6-
types: [trigger-test-deploy]
4+
workflow_dispatch:
75

86
permissions: write-all
97

108
env:
119
OPENSHIFT_NAMESPACE: 6cdc9e-tools
1210
IMAGE_NAME: eagle-admin
13-
PROD_PROMO_BRANCH: promotion/prod
14-
PROD_PROMO_PR_BRANCH: promotion/prod-pr
1511

1612
jobs:
17-
deploy:
18-
name: Deploy to Test
13+
build:
14+
name: Build and Push Image
1915
runs-on: ubuntu-latest
20-
outputs:
21-
COMMIT_SHA: ${{ steps.read-hash.outputs.SHA }}
2216
steps:
2317
- name: Checkout repository
24-
uses: actions/checkout@v3
25-
with:
26-
ref: "promotion/test"
27-
28-
- name: Retrieve previous commit hash
29-
id: read-hash
30-
run: echo "SHA=$(jq -r '.commit' state.json)" >> $GITHUB_OUTPUT
18+
uses: actions/checkout@v4
3119

32-
- name: Install OpenShift CLI
33-
run: |
34-
curl -LO "https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/openshift-client-linux.tar.gz"
35-
tar -xvzf openshift-client-linux.tar.gz
36-
sudo mv oc /usr/local/bin/
37-
rm -f openshift-client-linux.tar.gz
20+
- name: Get Short SHA
21+
id: short-sha
22+
run: echo "SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
3823

39-
- name: Log into OpenShift
40-
uses: redhat-actions/oc-login@v1
24+
- name: Login to OpenShift registry
25+
uses: docker/login-action@v3
4126
with:
42-
openshift_server_url: ${{ secrets.OPENSHIFT_URL }}
43-
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
44-
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
45-
46-
- name: Tag image
47-
run: |
48-
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:test ${{ env.IMAGE_NAME }}:test-backup
49-
oc -n ${{ env.OPENSHIFT_NAMESPACE }} tag --reference-policy='local' ${{ env.IMAGE_NAME }}:ci-latest ${{ env.IMAGE_NAME }}:test
27+
registry: ${{ secrets.OPENSHIFT_REPOSITORY }}
28+
username: ${{ secrets.OPENSHIFT_REPOSITORY_USERNAME }}
29+
password: ${{ secrets.OPENSHIFT_REPOSITORY_PASSWORD }}
5030

51-
sync-test-branch:
52-
name: Rebase test branch from develop
53-
needs: deploy
54-
runs-on: ubuntu-latest
55-
steps:
56-
- name: Checkout repository
57-
uses: actions/checkout@v3
58-
with:
59-
ref: "test"
60-
- run: |
61-
git fetch origin develop
62-
git rebase ${{needs.deploy.outputs.COMMIT_SHA}} test
63-
git push origin test
64-
65-
promotion:
66-
name: Create Promotion Pull Request
67-
needs: [deploy, sync-test-branch]
68-
runs-on: ubuntu-latest
69-
steps:
70-
# Update promotion/prod-pr with new commit hash
71-
- name: Checkout promotion/prod
72-
uses: actions/checkout@v3
31+
- name: Build and push Docker image
32+
uses: docker/build-push-action@v6
7333
with:
74-
ref: "${{ env.PROD_PROMO_BRANCH }}"
75-
- name: Update state.json
76-
run: |
77-
git config --global user.name "${{ github.actor }}"
78-
git config --global user.email "${{github.actor}}@users.noreply.github.com"
79-
git checkout -B ${{ env.PROD_PROMO_PR_BRANCH }}
80-
git reset --hard ${{ env.PROD_PROMO_BRANCH }}
81-
echo $(jq '.commit="${{ needs.deploy.outputs.COMMIT_SHA }}"' state.json) > state.json
82-
git commit -am "Promote commit ${{ needs.deploy.outputs.COMMIT_SHA }} to Production"
83-
git push --force origin ${{ env.PROD_PROMO_PR_BRANCH }}
84-
- name: Create or Update Pull Request
85-
run: |
86-
# Check if PR exists
87-
PR_URL=$(gh pr list --base "${{ env.PROD_PROMO_BRANCH }}" --head "${{ env.PROD_PROMO_PR_BRANCH }}" --json url --jq '.[0].url')
88-
if [ -z "$PR_URL" ]; then
89-
# Create PR if it doesn't exist
90-
gh pr create \
91-
--base "${{ env.PROD_PROMO_BRANCH }}" \
92-
--head "${{ env.PROD_PROMO_PR_BRANCH }}" \
93-
--title "Deploy to Prod Environment" \
94-
--body ":crown: *An automated PR*\n\nThis PR triggers a deployment to Production once it's fully merged." \
95-
--label "auto-pr,prod env,pipeline" \
96-
--draft
97-
else
98-
# Update PR if it exists
99-
gh pr edit "$PR_URL" \
100-
--title "Deploy to Prod Environment" \
101-
--body ":crown: *An automated PR*\n\nThis PR triggers a deployment to Production once it's fully merged." \
102-
--add-label "auto-pr,prod env,pipeline"
103-
fi
104-
env:
105-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
context: .
35+
push: true
36+
tags: |
37+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:test
38+
${{ secrets.OPENSHIFT_REPOSITORY }}/${{ env.OPENSHIFT_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ steps.short-sha.outputs.SHA }}
39+
labels: |
40+
commit.id=${{ github.sha }}
41+
commit.timestamp=${{ github.event.head_commit.timestamp }}

.yarn/install-state.gz

9.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)