Skip to content

Commit

Permalink
feat(netlify): inject netlify build environments into static site
Browse files Browse the repository at this point in the history
This should (hopefully) inject the netlify build environment
variables into the static site, so that we can display more
meaningful information about the deployment.
  • Loading branch information
bpas247 committed Jul 28, 2020
1 parent 02a71b1 commit 235946d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 10 additions & 0 deletions www/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,21 @@ const bootstrapVersion = require('bootstrap/package.json').version;

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

const netlify =
process.env.NETLIFY === 'true'
? {
pullRequest: process.env.PULL_REQUEST,
reviewId: process.env.REVIEW_ID,
branch: process.env.BRANCH,
}
: null;

const config = {
bootstrapVersion,
docsUrl: `https://getbootstrap.com/docs/${shortVersion}`,
version: require('../package.json').version,
cssHash: getIntegrity('bootstrap/dist/css/bootstrap.min.css'),
netlify,
};

module.exports = config;
15 changes: 7 additions & 8 deletions www/src/components/MasterDocsAlert.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@ import Alert from 'react-bootstrap/Alert';
import Container from 'react-bootstrap/Container';
import Row from 'react-bootstrap/Row';

function MasterDocsAlert() {
export default function MasterDocsAlert() {
const { netlify } = config;
let deploymentDetails = null;
if (process.env.NETLIFY) {
if (process.env.PULL_REQUEST === 'true') {
if (netlify) {
if (netlify.pullRequest) {
deploymentDetails = (
<span>
a{' '}
<Alert.Link
href={`https://github.com/react-bootstrap/react-bootstrap/pull/${process.env.REVIEW_ID}`}
href={`https://github.com/react-bootstrap/react-bootstrap/pull/${netlify.reviewId}`}
>
pull request
</Alert.Link>
</span>
);
} else {
deploymentDetails = `the ${process.env.BRANCH} branch`;
deploymentDetails = `the ${netlify.branch} branch`;
}
}
return process.env.NETLIFY ? (
return netlify ? (
<Container fluid>
<Row>
<Alert variant="warning" className="w-100">
Expand All @@ -35,5 +36,3 @@ function MasterDocsAlert() {
</Container>
) : null;
}

export default MasterDocsAlert;

0 comments on commit 235946d

Please sign in to comment.