Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Staging – uses staging API (api-stg.core.ac.uk)
VITE_APP_NAME=CORE Dashboard (staging)
VITE_APP_API_BASE_URL=https://api-stg.core.ac.uk
VITE_API_URL=https://api-stg.core.ac.uk
VITE_IDP_URL=https://api-stg.core.ac.uk
VITE_SENTRY_DSN=https://4d292e22294f991799b49f3ffa238ff7@o318858.ingest.us.sentry.io/4511235416981504
VITE_GA_TRACKING_CODE=
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: AKS deployment - core-frontend-dashboard
name: AKS Prod

on:
push:
Expand All @@ -12,6 +12,8 @@ env:
AKS_CLUSTER_NAME: core-frontend-kubernetes-cluster
NAMESPACE: core-frontend
DEPLOYMENT_NAME: core-frontend-dashboard
APP_ENV: production
KUBE_DIR: kube/prod
SENTRY_DSN: https://d116b39bd427449799cdd1516f6f97a1@sentry.io/2091955

jobs:
Expand Down Expand Up @@ -54,6 +56,7 @@ jobs:
docker buildx build \
--platform linux/arm64 \
--push \
--build-arg APP_ENV=${{ env.APP_ENV }} \
--build-arg SENTRY_DSN=${{ env.SENTRY_DSN }} \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
--build-arg GA_TRACKING_CODE=${{ secrets.GA_TRACKING_CODE }} \
Expand Down Expand Up @@ -82,13 +85,13 @@ jobs:

- name: Apply Service and HTTPRoute
run: |
kubectl apply -f kube/service.yaml
kubectl apply -f kube/httproute.yaml
kubectl apply -f ${{ env.KUBE_DIR }}/service.yaml
kubectl apply -f ${{ env.KUBE_DIR }}/httproute.yaml

- name: Deploy to AKS
run: |
export IMAGE="${{ steps.image.outputs.ref }}"
envsubst < kube/deployment.yaml | kubectl apply -f -
envsubst < ${{ env.KUBE_DIR }}/deployment.yaml | kubectl apply -f -

- name: Wait for rollout
run: |
Expand Down Expand Up @@ -133,7 +136,7 @@ jobs:
run: rm -f .npmrc

- name: Build web app
run: pnpm run build
run: pnpm run build:${{ env.APP_ENV }}
env:
NODE_OPTIONS: --max-old-space-size=4096
SENTRY_DSN: ${{ env.SENTRY_DSN }}
Expand Down
157 changes: 157 additions & 0 deletions .github/workflows/aks_deploy_stage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: AKS Stage

on:
push:
branches: [stage]
workflow_dispatch:

env:
ACR_NAME: corecontainers
IMAGE_NAME: core-frontend-dashboard-stage
RESOURCE_GROUP: core-frontend
AKS_CLUSTER_NAME: core-frontend-kubernetes-cluster
NAMESPACE: core-frontend-stage
DEPLOYMENT_NAME: core-frontend-dashboard
APP_ENV: staging
KUBE_DIR: kube/stage
SENTRY_DSN: https://d116b39bd427449799cdd1516f6f97a1@sentry.io/2091955

jobs:
build-and-deploy:
runs-on: ubuntu-24.04-arm
environment: azure
permissions:
id-token: write
contents: read
outputs:
release: ${{ steps.image.outputs.release }}
sha: ${{ github.sha }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set image reference
id: image
run: |
TAG=$(echo ${{ github.sha }} | cut -c1-7)
echo "ref=${{ env.ACR_NAME }}.azurecr.io/aks-${{ env.IMAGE_NAME }}:$TAG" >> $GITHUB_OUTPUT
echo "release=$TAG" >> $GITHUB_OUTPUT

- name: Azure Login
uses: azure/login@v2
with:
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

- name: Docker ACR Login
run: az acr login --name ${{ env.ACR_NAME }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker build and push
run: |
docker buildx build \
--platform linux/arm64 \
--push \
--build-arg APP_ENV=${{ env.APP_ENV }} \
--build-arg SENTRY_DSN=${{ env.SENTRY_DSN }} \
--build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} \
--build-arg GA_TRACKING_CODE=${{ secrets.GA_TRACKING_CODE }} \
--build-arg NPM_TOKEN=${{ secrets.NPM_TOKEN }} \
--build-arg API_KEY=${{ secrets.API_KEY }} \
--build-arg SENTRY_RELEASE=${{ steps.image.outputs.release }} \
-t ${{ steps.image.outputs.ref }} .

- name: Get AKS credentials
run: |
az aks get-credentials \
--resource-group ${{ env.RESOURCE_GROUP }} \
--name ${{ env.AKS_CLUSTER_NAME }} \
--admin \
--overwrite-existing

- name: Sync secrets to AKS
run: |
kubectl create secret generic core-frontend-dashboard-secrets \
--namespace ${{ env.NAMESPACE }} \
--from-literal=SENTRY_DSN="${{ env.SENTRY_DSN }}" \
--from-literal=SENTRY_AUTH_TOKEN="${{ secrets.SENTRY_AUTH_TOKEN }}" \
--from-literal=GA_TRACKING_CODE="${{ secrets.GA_TRACKING_CODE }}" \
--from-literal=API_KEY="${{ secrets.API_KEY }}" \
--dry-run=client -o yaml | kubectl apply -f -

- name: Apply Service and HTTPRoute
run: |
kubectl apply -f ${{ env.KUBE_DIR }}/service.yaml
kubectl apply -f ${{ env.KUBE_DIR }}/httproute.yaml

- name: Deploy to AKS
run: |
export IMAGE="${{ steps.image.outputs.ref }}"
envsubst < ${{ env.KUBE_DIR }}/deployment.yaml | kubectl apply -f -

- name: Wait for rollout
run: |
kubectl rollout status deployment/${{ env.DEPLOYMENT_NAME }} \
--namespace ${{ env.NAMESPACE }} \
--timeout=300s

upload-sentry-sourcemaps:
name: Upload Sentry sourcemaps (stage)
needs: [build-and-deploy]
runs-on: ubuntu-latest
environment: azure
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.build-and-deploy.outputs.sha }}

- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm

- name: Configure npm auth for @oacore
run: |
printf "@oacore:registry=https://npm.pkg.github.com\n//npm.pkg.github.com/:_authToken=%s\n" "${{ secrets.NPM_TOKEN }}" > .npmrc

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Remove npm auth
if: always()
run: rm -f .npmrc

- name: Build web app
run: pnpm run build:${{ env.APP_ENV }}
env:
NODE_OPTIONS: --max-old-space-size=4096
SENTRY_DSN: ${{ env.SENTRY_DSN }}
SENTRY_RELEASE: ${{ needs.build-and-deploy.outputs.release }}
GA_TRACKING_CODE: ${{ secrets.GA_TRACKING_CODE }}
API_KEY: ${{ secrets.API_KEY }}

- name: Create Sentry release
uses: getsentry/action-release@v3
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: oacore
SENTRY_PROJECT: dashboard-pk
with:
environment: production
release: ${{ needs.build-and-deploy.outputs.release }}
sourcemaps: ./dist/assets
url_prefix: '~/assets'
Loading
Loading