Provide mechanism to specify a RADISH_URL that differentiates between different destination end points depending on if running from staging or from production or ...

This commit is contained in:
Colby Gutierrez-Kraybill 2024-05-20 22:41:44 -04:00
parent 45a2e68b20
commit 099235e6d9
3 changed files with 12 additions and 2 deletions

View file

@ -99,6 +99,7 @@ jobs:
SLACK_WEBHOOK_CIRCLECI_NOTIFICATIONS: ${{ secrets.SLACK_WEBHOOK_CIRCLECI_NOTIFICATIONS }} # TODO: rename or replace
SLACK_WEBHOOK_ENGINEERING: ${{ secrets.SLACK_WEBHOOK_ENGINEERING }}
SLACK_WEBHOOK_MODS: ${{ secrets.SLACK_WEBHOOK_MODS }}
RADISH_URL: ${{ vars.RADISH_URL }}
- name: integration tests
if: ${{ env.SCRATCH_SHOULD_DEPLOY == 'true' }}
run: |

View file

@ -7,6 +7,7 @@ const routeJson = require('../src/routes.json');
const FASTLY_SERVICE_ID = process.env.FASTLY_SERVICE_ID || '';
const S3_BUCKET_NAME = process.env.S3_BUCKET_NAME || '';
const RADISH_URL = process.env.RADISH_URL || '';
const fastly = require('./lib/fastly-extended')(process.env.FASTLY_API_KEY, FASTLY_SERVICE_ID);
@ -18,7 +19,15 @@ const extraAppRoutes = [
'/[^/]*.html$'
];
const routes = routeJson.map(
const routeJsonPreProcessed = routeJson.map(
(route) => {
if (route.redirect) {
route.redirect.replace('RADISH_URL',RADISH_URL);
}
return route;
}
);
const routes = routeJsonPreProcessed.map(
route => defaults({}, {pattern: fastlyConfig.expressPatternToRegex(route.pattern)}, route)
);

View file

@ -3,7 +3,7 @@
"name": "about",
"pattern": "^/about/?$",
"routeAlias": "/about/?$",
"redirect": "https://scratch.pizza/"
"redirect": "RADISH_URL/"
},
{
"name": "annual-report",