mirror of
https://github.com/scratchfoundation/scratch-www.git
synced 2024-11-24 08:08:18 -05:00
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:
parent
45a2e68b20
commit
099235e6d9
3 changed files with 12 additions and 2 deletions
1
.github/workflows/ci-cd.yml
vendored
1
.github/workflows/ci-cd.yml
vendored
|
@ -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: |
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "about",
|
||||
"pattern": "^/about/?$",
|
||||
"routeAlias": "/about/?$",
|
||||
"redirect": "https://scratch.pizza/"
|
||||
"redirect": "RADISH_URL/"
|
||||
},
|
||||
{
|
||||
"name": "annual-report",
|
||||
|
|
Loading…
Reference in a new issue