Skip to content

Commit

Permalink
fix(ci): allowed_origins different for TEST and PROD (#494)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerekRoberts authored Nov 21, 2024
1 parent 0577cfb commit 525d6f7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 16 additions & 1 deletion .github/workflows/.deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
# Nothing! Only `secrets: inherit` is required

### Typical / recommended
allowed_origins:
description: Allowed origins for CORS
required: false
type: string
environment:
description: GitHub/OpenShift environment; usually PR number, test or prod
default: ''
Expand All @@ -33,6 +37,7 @@ jobs:
name: Deploy (init)
environment: ${{ inputs.environment }}
outputs:
allowed_origins: ${{ steps.allowed_origins.outputs.allowed_origins }}
route: ${{ steps.route.outputs.route }}
runs-on: ubuntu-latest
steps:
Expand All @@ -45,6 +50,16 @@ jobs:
echo "route=${{ inputs.target }}" >> $GITHUB_OUTPUT
fi
- name: ALLOWED_ORIGINS
id: allowed_origins
run: |
# If not set, use default routes
if [ -z ${{ inputs.allowed_origins }} ]; then
echo "allowed_origins=https://${{ github.event.repository.name }}-$(( ${{ github.event.number }} % 50 ))-frontend.apps.silver.devops.gov.bc.ca" >> $GITHUB_OUTPUT
else
echo "allowed_origins=${{ inputs.allowed_origins }}" >> $GITHUB_OUTPUT
fi
- name: OpenShift Init
uses: bcgov-nr/action-deployer-openshift@v3.0.1
with:
Expand Down Expand Up @@ -94,7 +109,7 @@ jobs:
-p AWS_COGNITO_ISSUER_URI=https://cognito-idp.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.VITE_USER_POOLS_ID }}
-p DASHBOARD_JOB_IDIR_USERS=${{ vars.DASHBOARD_JOB_IDIR_USERS }}
-p WMS_LAYERS_WHITELIST_USERS=${{ vars.WMS_LAYERS_WHITELIST_USERS }}
-p ALLOWED_ORIGINS=https://${{ github.event.repository.name }}-${{ needs.init.outputs.route }}-frontend.apps.silver.devops.gov.bc.ca
-p ALLOWED_ORIGINS=${{ needs.init.outputs.allowed_origins }}
verification_path: /actuator/health
- name: frontend
file: frontend/openshift.deploy.yml
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
secrets: inherit
uses: ./.github/workflows/.deploy.yml
with:
allowed_origins: https://silva-test.nrs.gov.bc.ca/
environment: test
tag: ${{ needs.init.outputs.pr }}
target: test
Expand All @@ -40,6 +41,7 @@ jobs:
secrets: inherit
uses: ./.github/workflows/.deploy.yml
with:
allowed_origins: https://silva.nrs.gov.bc.ca/
environment: prod
tag: ${{ needs.init.outputs.pr }}
target: prod
Expand Down

0 comments on commit 525d6f7

Please sign in to comment.