Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): allowed_origins different for TEST and PROD #494

Merged
merged 5 commits into from
Nov 21, 2024
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
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
Loading