From 5b459c692c887cd95db264bb958c31b1471bc685 Mon Sep 17 00:00:00 2001 From: Tom Elliott Date: Thu, 24 Aug 2023 14:43:16 +0100 Subject: [PATCH] EXUI-266: Configure github action to update preview deployment id (#3230) --- .../populate-preview-deployment-id.yaml | 29 +++++++++++++++++++ api/lib/http/index.ts | 4 +++ .../xui-webapp/values.preview.template.yaml | 1 + 3 files changed, 34 insertions(+) create mode 100644 .github/workflows/populate-preview-deployment-id.yaml diff --git a/.github/workflows/populate-preview-deployment-id.yaml b/.github/workflows/populate-preview-deployment-id.yaml new file mode 100644 index 0000000000..6597c657c4 --- /dev/null +++ b/.github/workflows/populate-preview-deployment-id.yaml @@ -0,0 +1,29 @@ +name: Populate Preview Deployment ID + +on: + pull_request: + branches: + - master + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: tibdex/github-app-token@v1 + id: generate-token + with: + app_id: ${{ secrets.HMCTS_GITHUB_EXUI_APP_ID }} + private_key: ${{ secrets.HMCTS_GITHUB_EXUI_PRIVATE_KEY }} + - uses: actions/checkout@v3 + with: + token: ${{ steps.generate-token.outputs.token }} + - name: Populate preview deployment ID + run: | + sed -i 's/PREVIEW_DEPLOYMENT_ID:.*/PREVIEW_DEPLOYMENT_ID: exui-preview-deployment-${{ github.event.number }}/' charts/xui-webapp/values.preview.template.yaml + shell: bash + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "${{ github.event.pull_request.head.ref }}: Setting Preview Deployment ID" diff --git a/api/lib/http/index.ts b/api/lib/http/index.ts index b1907eaf62..5bb7ebcf1f 100644 --- a/api/lib/http/index.ts +++ b/api/lib/http/index.ts @@ -2,7 +2,11 @@ import axios, { AxiosInstance } from 'axios'; import { errorInterceptor, requestInterceptor, successInterceptor } from '../interceptors'; export const http: AxiosInstance = axios.create({}); +const previewDeploymentId: string = process.env.PREVIEW_DEPLOYMENT_ID; +if (previewDeploymentId) { + axios.defaults.headers.common['hmcts-deployment-id'] = previewDeploymentId; +} axios.defaults.headers.common['Content-Type'] = 'application/json'; http.interceptors.request.use(requestInterceptor); http.interceptors.response.use(successInterceptor, errorInterceptor); diff --git a/charts/xui-webapp/values.preview.template.yaml b/charts/xui-webapp/values.preview.template.yaml index 0b6f1835f1..130e2808c7 100644 --- a/charts/xui-webapp/values.preview.template.yaml +++ b/charts/xui-webapp/values.preview.template.yaml @@ -23,6 +23,7 @@ nodejs: SERVICES_CASE_JUDICIAL_API: http://rd-judicial-api-aat.service.core-compute-aat.internal SERVICES_LOCATION_REF_API_URL: http://rd-location-ref-api-aat.service.core-compute-aat.internal FEATURE_ACCESS_MANAGEMENT_ENABLED: true + PREVIEW_DEPLOYMENT_ID: exui-preview-deployment-3230 keyVaults: rpx: secrets: