Skip to content

Commit

Permalink
feat(frontend): make the frontend use env var as version (#1093)
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil authored Aug 11, 2019
1 parent ac8f4c0 commit 3b39872
Showing 21 changed files with 80 additions and 66 deletions.
10 changes: 6 additions & 4 deletions .k8s/frontend/deployment.dev.yml
Original file line number Diff line number Diff line change
@@ -36,13 +36,15 @@ spec:
env:
- name: API_URL
value: "${API_URL}/api/v1"
- name: SUGGEST_URL
value: "${NLP_URL}/api/suggest"
- name: ENVIRONMENT
value: ${ENVIRONMENT}
- name: FRONTEND_HOST
value: ${FRONTEND_HOST}
- name: PIWIK_URL
value: ${CI_PIWIK_URL}
- name: PIWIK_SITE_ID
value: ${CI_PIWIK_SITE_ID}
- name: PIWIK_URL
value: ${CI_PIWIK_URL}
- name: SUGGEST_URL
value: "${NLP_URL}/api/suggest"
- name: VERSION
value: "${VERSION}"
18 changes: 10 additions & 8 deletions .k8s/frontend/deployment.prod.yml
Original file line number Diff line number Diff line change
@@ -36,15 +36,17 @@ spec:
env:
- name: API_URL
value: "${API_URL}/api/v1"
- name: SUGGEST_URL
value: "${NLP_URL}/api/suggest"
- name: PIWIK_URL
value: ${CI_PIWIK_URL}
- name: ENVIRONMENT
value: ${ENVIRONMENT}
- name: FRONTEND_HOST
value: ${FRONTEND_HOST}
- name: PIWIK_SITE_ID
value: ${CI_PIWIK_SITE_ID}
- name: PIWIK_URL
value: ${CI_PIWIK_URL}
- name: SENTRY_PUBLIC_DSN
value: ${CI_SENTRY_PUBLIC_DSN}
- name: FRONTEND_HOST
value: ${FRONTEND_HOST}
- name: ENVIRONMENT
value: ${ENVIRONMENT}
- name: SUGGEST_URL
value: "${NLP_URL}/api/suggest"
- name: VERSION
value: "${VERSION}"
16 changes: 8 additions & 8 deletions packages/code-du-travail-frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -5,19 +5,19 @@ module.exports = withSourceMaps({
useFileSystemPublicRoutes: false,

publicRuntimeConfig: {
API_URL: process.env.API_URL || "http://127.0.0.1:1337/api/v1",
API_ADDRESS: "https://api-adresse.data.gouv.fr/search",
API_DILA2SQL_URL:
process.env.API_DILA2SQL_URL ||
"https://api.dila2sql.num.social.gouv.fr/v1",
API_SIRET2IDCC_URL:
process.env.API_SIRET2IDCC_URL || "https://siret2idcc.num.social.gouv.fr",
SUGGEST_URL: process.env.SUGGEST_URL || "http://127.0.0.1:5000/api/suggest",
API_ADDRESS: "https://api-adresse.data.gouv.fr/search",
PACKAGE_VERSION: require("./package.json").version,
SENTRY_PUBLIC_DSN: process.env.SENTRY_PUBLIC_DSN,
PIWIK_URL: process.env.PIWIK_URL,
PIWIK_SITE_ID: process.env.PIWIK_SITE_ID,
API_URL: process.env.API_URL || "http://127.0.0.1:1337/api/v1",
FRONTEND_PORT: process.env.FRONTEND_PORT,
NODE_ENV: process.env.NODE_ENV
NODE_ENV: process.env.NODE_ENV,
PACKAGE_VERSION: process.env.VERSION || require("./package.json").version,
PIWIK_SITE_ID: process.env.PIWIK_SITE_ID,
PIWIK_URL: process.env.PIWIK_URL,
SENTRY_PUBLIC_DSN: process.env.SENTRY_PUBLIC_DSN,
SUGGEST_URL: process.env.SUGGEST_URL || "http://127.0.0.1:5000/api/suggest"
}
});
Original file line number Diff line number Diff line change
@@ -476,7 +476,7 @@ exports[`<About /> should render 1`] = `
class="c21"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -487,7 +487,7 @@ exports[`<About /> should render 1`] = `
class="c21"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1036,7 +1036,7 @@ exports[`<Annuaire /> should render 1`] = `
class="c41"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1047,7 +1047,7 @@ exports[`<Annuaire /> should render 1`] = `
class="c41"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1210,7 +1210,7 @@ exports[`<CodeDuTravail /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1221,7 +1221,7 @@ exports[`<CodeDuTravail /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -2062,7 +2062,7 @@ exports[`<DroitDuTravail /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -2073,7 +2073,7 @@ exports[`<DroitDuTravail /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1210,7 +1210,7 @@ exports[`<FicheMT /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1221,7 +1221,7 @@ exports[`<FicheMT /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1218,7 +1218,7 @@ exports[`<FicheSP /> should render 1`] = `
class="c49"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1229,7 +1229,7 @@ exports[`<FicheSP /> should render 1`] = `
class="c49"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1063,7 +1063,7 @@ exports[`<Home /> should render 1`] = `
class="c41"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1074,7 +1074,7 @@ exports[`<Home /> should render 1`] = `
class="c41"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -853,7 +853,7 @@ exports[`<MentionLegales /> should render 1`] = `
class="c28"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -864,7 +864,7 @@ exports[`<MentionLegales /> should render 1`] = `
class="c28"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1439,7 +1439,7 @@ exports[`<ModelesDeCourriers /> should render 1`] = `
class="c57"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1450,7 +1450,7 @@ exports[`<ModelesDeCourriers /> should render 1`] = `
class="c57"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -786,7 +786,7 @@ exports[`<Outils /> should render 1`] = `
class="c35"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -797,7 +797,7 @@ exports[`<Outils /> should render 1`] = `
class="c35"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -1210,7 +1210,7 @@ exports[`<Question /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -1221,7 +1221,7 @@ exports[`<Question /> should render 1`] = `
class="c48"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -772,7 +772,7 @@ exports[`<Recherche /> should render 1`] = `
class="c33"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -783,7 +783,7 @@ exports[`<Recherche /> should render 1`] = `
class="c33"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Original file line number Diff line number Diff line change
@@ -741,7 +741,7 @@ exports[`<Theme /> should render 1`] = `
class="c32"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -752,7 +752,7 @@ exports[`<Theme /> should render 1`] = `
class="c32"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
36 changes: 23 additions & 13 deletions packages/code-du-travail-frontend/src/layout/Footer.js
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@ import ServiceRenseignementModal from "../common/ServiceRenseignementModal";

const { publicRuntimeConfig } = getConfig();

const GITHUB_REPO = "https://github.com/SocialGouv/code-du-travail-numerique";

const Footer = () => (
<StyledFooter>
<Section>
@@ -56,27 +58,35 @@ const Footer = () => (
<List>
<StyledListItem>
<a
href={
"https://github.com/SocialGouv/code-du-travail-numerique/tree/v" +
href={`${GITHUB_REPO}/tree/${
publicRuntimeConfig.PACKAGE_VERSION
}
}`}
target="_blank"
rel="noopener noreferrer"
>
Contribuer sur Github
</a>
</StyledListItem>
<StyledListItem>
<a
href={
"https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/v" +
publicRuntimeConfig.PACKAGE_VERSION
}
target="_blank"
rel="noopener noreferrer"
>
Journal des modifications
</a>
{(() => {
const packageVersion =
publicRuntimeConfig.PACKAGE_VERSION || "";
const isTag = packageVersion[0] === "v";
const path = isTag
? "releases/tag"
: packageVersion === "master"
? "commits"
: "compare";
return (
<a
href={`${GITHUB_REPO}/${path}/${packageVersion}`}
target="_blank"
rel="noopener noreferrer"
>
Journal des modifications
</a>
);
})()}
</StyledListItem>
</List>
</Category>
Original file line number Diff line number Diff line change
@@ -268,7 +268,7 @@ exports[`<Footer /> should render 1`] = `
class="c12"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/tree/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
@@ -279,7 +279,7 @@ exports[`<Footer /> should render 1`] = `
class="c12"
>
<a
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vx.y.z"
href="https://github.com/SocialGouv/code-du-travail-numerique/releases/tag/vX.Y.Z"
rel="noopener noreferrer"
target="_blank"
>
Loading

0 comments on commit 3b39872

Please sign in to comment.