Skip to content

Commit

Permalink
Added logic to check whether in staging or prod.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbrunvoll committed Apr 2, 2024
1 parent fce76cb commit d938c16
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,31 @@ jobs:
ATB_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ github.event_name == 'release' && 'atb-mobility-platform.firebaseapp.com' || 'atb-mobility-platform-staging.firebaseapp.com' }}
ATB_NEXT_PUBLIC_FIREBASE_APP_ID=${{ github.event_name == 'release' && '1:827196677776:web:c4b1d8924bb5778bf50215' || '1:939812594010:web:0308b2a9cdc80b0d069363' }}
ATB_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ github.event_name == 'release' && '' || '' }}
ATB_NEXT_PUBLIC_IN_STAGING=${{ github.event_name == 'atb-mobility-platform-staging'}}
NFK_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT=67.280357
NFK_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG=14.404916
NFK_NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ github.event_name == 'release' && 'nfk-prod' || 'nfk-staging'}}
NFK_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=${{ github.event_name == 'release' && 'AIzaSyDGwZLvjhRJmxiU9BOkbYn9P78QTJsAaBQ' || 'AIzaSyDU18r0GPKIGcVxA3Zj_zgkrtqaUfcOHGM' }}
NFK_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ github.event_name == 'release' && 'nfk-prod.firebaseapp.com' || 'nfk-staging.firebaseapp.com' }}
NFK_NEXT_PUBLIC_FIREBASE_APP_ID=${{ github.event_name == 'release' && '1:638315587956:web:51e95a11a03f27dc9ca421' || '1:793301954236:web:908723b8ded2824cadeab9' }}
NFK_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ github.event_name == 'release' && '' || '' }}
NFK_NEXT_PUBLIC_IN_STAGING=${{ github.event_name == 'nfk-staging'}}
FRAM_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT=62.4705
FRAM_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG=6.1533
FRAM_NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ github.event_name == 'release' && 'fram-prod-a7850' || 'fram-staging'}}
FRAM_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=${{ github.event_name == 'release' && 'AIzaSyBw6YwFJV__iw6Qp7bLdcwcUKtr2f02H2M' || 'AIzaSyBTsBaCnXcCFPQUaXTPLSMGfydaTpaLDrs' }}
FRAM_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ github.event_name == 'release' && 'fram-prod-a7850.firebaseapp.com' || 'fram-staging.firebaseapp.com' }}
FRAM_NEXT_PUBLIC_FIREBASE_APP_ID=${{ github.event_name == 'release' && '1:717595301444:web:1e16129330d562f1b3ce11' || '1:312905478211:web:41c6f9db83ae5ef0efa4f6' }}
FRAM_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ github.event_name == 'release' && 'G-KS45JBFWF4' || '' }}
FRAM_NEXT_PUBLIC_IN_STAGING=${{ github.event_name == 'fram-staging'}}
TROMS_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT=69.665229
TROMS_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG=18.9070347
TROMS_NEXT_PUBLIC_FIREBASE_PROJECT_ID=${{ github.event_name == 'release' && '' || 'troms-staging'}}
TROMS_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=${{ github.event_name == 'release' && '' || 'AIzaSyCtJMximw0SL9N8YNH21TWDO0s_mv_9crE' }}
TROMS_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ github.event_name == 'release' && '' || 'troms-staging.firebaseapp.com' }}
TROMS_NEXT_PUBLIC_FIREBASE_APP_ID=${{ github.event_name == 'release' && '' || '1:973624729382:web:a84d8a489613a14be12be7' }}
TROMS_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=''
TROMS_NEXT_PUBLIC_IN_STAGING=${{ github.event_name == 'troms-staging'}}
secrets:
github_pat: ${{ secrets.GH_PAT }}
build_secrets: |
Expand Down
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ ARG ATB_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ARG ATB_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ARG ATB_NEXT_PUBLIC_FIREBASE_APP_ID
ARG ATB_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ARG ATB_NEXT_PUBLIC_IN_STAGING

ARG NFK_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT
ARG NFK_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG
Expand All @@ -30,6 +31,7 @@ ARG NFK_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ARG NFK_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ARG NFK_NEXT_PUBLIC_FIREBASE_APP_ID
ARG NFK_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ARG NFK_NEXT_PUBLIC_IN_STAGING

ARG FRAM_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT
ARG FRAM_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG
Expand All @@ -38,6 +40,7 @@ ARG FRAM_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ARG FRAM_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ARG FRAM_NEXT_PUBLIC_FIREBASE_APP_ID
ARG FRAM_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ARG FRAM_NEXT_PUBLIC_IN_STAGING

ARG TROMS_NEXT_PUBLIC_MAPBOX_DEFAULT_LAT
ARG TROMS_NEXT_PUBLIC_MAPBOX_DEFAULT_LNG
Expand All @@ -46,6 +49,7 @@ ARG TROMS_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ARG TROMS_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ARG TROMS_NEXT_PUBLIC_FIREBASE_APP_ID
ARG TROMS_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ARG TROMS_NEXT_PUBLIC_IN_STAGING

# Generate GraphQL files
RUN yarn generate
Expand All @@ -59,6 +63,7 @@ ENV NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=$ATB_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ENV NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=$ATB_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ENV NEXT_PUBLIC_FIREBASE_APP_ID=$ATB_NEXT_PUBLIC_FIREBASE_APP_ID
ENV NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=$ATB_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ENV NEXT_PUBLIC_IN_STAGING=$ATB_NEXT_PUBLIC_IN_STAGING

RUN --mount=type=secret,id=ATB_NEXT_PUBLIC_MAPBOX_API_TOKEN \
--mount=type=secret,id=ATB_NEXT_PUBLIC_MAPBOX_STOP_PLACES_STYLE_URL \
Expand All @@ -75,6 +80,7 @@ ENV NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=$NFK_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY
ENV NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=$NFK_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ENV NEXT_PUBLIC_FIREBASE_APP_ID=$NFK_NEXT_PUBLIC_FIREBASE_APP_ID
ENV NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=$NFK_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ENV NEXT_PUBLIC_IN_STAGING=$NFK_NEXT_PUBLIC_IN_STAGING

RUN --mount=type=secret,id=NFK_NEXT_PUBLIC_MAPBOX_API_TOKEN \
--mount=type=secret,id=NFK_NEXT_PUBLIC_MAPBOX_STOP_PLACES_STYLE_URL \
Expand All @@ -91,6 +97,7 @@ ENV NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=$FRAM_NEXT_PUBLIC_FIREBASE_PUBLIC_API_KE
ENV NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=$FRAM_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ENV NEXT_PUBLIC_FIREBASE_APP_ID=$FRAM_NEXT_PUBLIC_FIREBASE_APP_ID
ENV NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=$FRAM_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ENV NEXT_PUBLIC_IN_STAGING=$FRAM_NEXT_PUBLIC_IN_STAGING

RUN --mount=type=secret,id=FRAM_NEXT_PUBLIC_MAPBOX_API_TOKEN \
--mount=type=secret,id=FRAM_NEXT_PUBLIC_MAPBOX_STOP_PLACES_STYLE_URL \
Expand All @@ -107,6 +114,7 @@ ENV NEXT_PUBLIC_FIREBASE_PUBLIC_API_KEY=$TROMS_NEXT_PUBLIC_FIREBASE_PUBLIC_API_K
ENV NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=$TROMS_NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN
ENV NEXT_PUBLIC_FIREBASE_APP_ID=$TROMS_NEXT_PUBLIC_FIREBASE_APP_ID
ENV NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID=$TROMS_NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID
ENV NEXT_PUBLIC_IN_STAGING=$TROMS_NEXT_PUBLIC_IN_STAGING

RUN --mount=type=secret,id=TROMS_NEXT_PUBLIC_MAPBOX_API_TOKEN \
--mount=type=secret,id=TROMS_NEXT_PUBLIC_MAPBOX_STOP_PLACES_STYLE_URL \
Expand Down
18 changes: 13 additions & 5 deletions next-sitemap.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/** @type {import('next-sitemap').IConfig} */

function getSiteUrl() {
function getEnvironmentUrls() {
const orgId = process.env.NEXT_PUBLIC_PLANNER_ORG_ID;
const org = require(`./orgs/${orgId}.json`);
return org.urls.travelPlannerUrl.href;
return org.urls.sitemapUrls;
}

const siteUrl = getSiteUrl();
const prod = process.env.NODE_ENV === 'production';
const environmentUrls = getEnvironmentUrls();

let environment;
if (process.env.NEXT_PUBLIC_IN_STAGING) {
environment = 'staging';
} else if (!process.env.NEXT_PUBLIC_IN_STAGING) {
environment = 'prod';
} else {
environment = 'dev';
}

module.exports = {
siteUrl: prod ? siteUrl : 'http://localhost:3000',
siteUrl: environmentUrls[environment],
generateIndexSitemap: false,
sitemapSize: 7000,
generateRobotsTxt: true,
Expand Down
6 changes: 4 additions & 2 deletions orgs/atb.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"no": "https://www.atb.no/priser/",
"default": "https://www.atb.no/priser/"
},
"travelPlannerUrl": {
"href": "https://reise.atb.no/"
"sitemapUrls": {
"dev": "http://localhost:3000",
"staging": "https://atb-staging.planner-web.mittatb.no/",
"prod": "https://reise.atb.no/"
}
},
"journeyApiConfigurations": {
Expand Down
6 changes: 4 additions & 2 deletions orgs/fram.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
"nn": "https://frammr.no/billettar/billettar-og-prisar/?sprak=11",
"default": "https://frammr.no/billettar/billettar-og-prisar/"
},
"travelPlannerUrl": {
"href": "https://reise.frammr.no/"
"sitemapUrls": {
"dev": "http://localhost:3000",
"staging": "https://fram-staging.planner-web.mittatb.no/",
"prod": "https://reise.frammr.no/"
}
},
"journeyApiConfigurations": {
Expand Down
6 changes: 4 additions & 2 deletions orgs/nfk.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
"no": "https://www.reisnordland.no/priser-pa-buss",
"default": "https://www.reisnordland.no/priser-pa-buss"
},
"travelPlannerUrl": {
"href": "https://reise.reisnordland.no/"
"sitemapUrls": {
"dev": "http://localhost:3000",
"staging": "https://nfk-staging.planner-web.mittatb.no/",
"prod": "https://www.reisnordland.no/"
}
},
"journeyApiConfigurations": {
Expand Down
18 changes: 15 additions & 3 deletions orgs/schema-validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,21 @@
"ticketsUrl": {
"$ref": "#/definitions/TranslatableUrl"
},
"travelPlannerUrl": {
"name": {
"type": "string"
"sitemapUrls": {
"dev": {
"name": {
"type": "string"
}
},
"staging": {
"name": {
"type": "string"
}
},
"prod": {
"name": {
"type": "string"
}
}
}
},
Expand Down
7 changes: 5 additions & 2 deletions orgs/troms.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@
"no": "https://fylkestrafikk.no/meny/billetter-og-priser",
"default": "https://fylkestrafikk.no/meny/billetter-og-priser"
},
"travelPlannerUrl": {
"href": "https://reise.fylkestrafikk.no/"

"sitemapUrls": {
"dev": "http://localhost:3000",
"staging": "https://troms-staging.planner-web.mittatb.no/",
"prod": "https://reise.fylkestrafikk.no/"
}
},
"journeyApiConfigurations": {
Expand Down

0 comments on commit d938c16

Please sign in to comment.