Skip to content

Commit 999b0bd

Browse files
author
Michael James
committed
chore(storybook): Added publishing of PR storybook to S3 bucket
1 parent 16821bc commit 999b0bd

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
/coverage
88

99
# production
10-
/build
1110
/dist
1211

1312
# misc

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ node_js:
33
- 7
44
cache:
55
yarn: true
6+
directories:
7+
- node_modules
8+
9+
before_install:
10+
- pip install --user awscli
11+
- export PATH=$PATH:$HOME/.local/bin
12+
613
script:
714
- yarn run coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
815
- yarn run build
16+
- yarn run build-storybook
17+
- node ./build/aws-deploy.js
18+
19+
after_script:
20+
# TODO comment on PR with link to PR storybook on S3 and notify slack room
21+
- echo "PR storybook can be found at:"
22+
- echo "http://react-audio-vis-prs.s3-ap-southeast-2.amazonaws.com/$TRAVIS_PULL_REQUEST_BRANCH/index.html"

build/aws-deploy.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const execSync = require('child_process').execSync;
2+
3+
const isPrBuild = (prBranch) => {
4+
return prBranch && prBranch !== "master";
5+
};
6+
7+
const staticSizeNotTooLarge = (staticBookSize) => {
8+
const tenMB = 10 * (2 << 9);
9+
return !isNaN(staticBookSize) && staticBookSize < tenMB;
10+
};
11+
12+
const {TRAVIS_PULL_REQUEST_BRANCH: prBranch} = process.env;
13+
console.log(prBranch);
14+
if (isPrBuild(prBranch)) {
15+
const result = execSync(`du -sk storybook-static | sed 's/[^0-9]*//g'`);
16+
const staticBookSize = Number.parseInt(result.toString());
17+
18+
if (staticSizeNotTooLarge(staticBookSize)) {
19+
const result = execSync(
20+
`aws s3 cp ${__dirname}/../storybook-static s3://react-audio-vis-prs/${prBranch} --recursive`,
21+
{stdio: [0, 1, 2]}
22+
);
23+
}
24+
}

0 commit comments

Comments
 (0)