Skip to content

Commit 235946d

Browse files
committed
feat(netlify): inject netlify build environments into static site
This should (hopefully) inject the netlify build environment variables into the static site, so that we can display more meaningful information about the deployment.
1 parent 02a71b1 commit 235946d

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

www/config.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@ const bootstrapVersion = require('bootstrap/package.json').version;
1313

1414
const shortVersion = bootstrapVersion.split('.').slice(0, 2).join('.');
1515

16+
const netlify =
17+
process.env.NETLIFY === 'true'
18+
? {
19+
pullRequest: process.env.PULL_REQUEST,
20+
reviewId: process.env.REVIEW_ID,
21+
branch: process.env.BRANCH,
22+
}
23+
: null;
24+
1625
const config = {
1726
bootstrapVersion,
1827
docsUrl: `https://getbootstrap.com/docs/${shortVersion}`,
1928
version: require('../package.json').version,
2029
cssHash: getIntegrity('bootstrap/dist/css/bootstrap.min.css'),
30+
netlify,
2131
};
2232

2333
module.exports = config;

www/src/components/MasterDocsAlert.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@ import Alert from 'react-bootstrap/Alert';
33
import Container from 'react-bootstrap/Container';
44
import Row from 'react-bootstrap/Row';
55

6-
function MasterDocsAlert() {
6+
export default function MasterDocsAlert() {
7+
const { netlify } = config;
78
let deploymentDetails = null;
8-
if (process.env.NETLIFY) {
9-
if (process.env.PULL_REQUEST === 'true') {
9+
if (netlify) {
10+
if (netlify.pullRequest) {
1011
deploymentDetails = (
1112
<span>
1213
a{' '}
1314
<Alert.Link
14-
href={`https://github.com/react-bootstrap/react-bootstrap/pull/${process.env.REVIEW_ID}`}
15+
href={`https://github.com/react-bootstrap/react-bootstrap/pull/${netlify.reviewId}`}
1516
>
1617
pull request
1718
</Alert.Link>
1819
</span>
1920
);
2021
} else {
21-
deploymentDetails = `the ${process.env.BRANCH} branch`;
22+
deploymentDetails = `the ${netlify.branch} branch`;
2223
}
2324
}
24-
return process.env.NETLIFY ? (
25+
return netlify ? (
2526
<Container fluid>
2627
<Row>
2728
<Alert variant="warning" className="w-100">
@@ -35,5 +36,3 @@ function MasterDocsAlert() {
3536
</Container>
3637
) : null;
3738
}
38-
39-
export default MasterDocsAlert;

0 commit comments

Comments
 (0)