Skip to content

Commit

Permalink
feat: migrated to new github pages deploy solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftwork committed Dec 16, 2019
1 parent 018a3e1 commit 3e4468f
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cd.yml
Expand Up @@ -48,6 +48,6 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Deploy documentation package to GitHub Pages
run: npm run docs:deploy -- -- -- --ci --source-branch=HEAD
run: npm run docs:deploy
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
130 changes: 130 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -51,7 +51,6 @@
"@storybook/addon-notes": "5.2.8",
"@storybook/addons": "5.2.8",
"@storybook/react": "5.2.8",
"@storybook/storybook-deployer": "2.8.1",
"@typescript-eslint/eslint-plugin": "2.11.0",
"@typescript-eslint/parser": "2.11.0",
"babel-loader": "8.0.6",
Expand All @@ -62,6 +61,7 @@
"eslint-config-prettier": "6.7.0",
"eslint-plugin-prettier": "3.1.1",
"eslint-plugin-react": "7.17.0",
"gh-pages": "2.1.1",
"gulp": "4.0.2",
"gulp-eslint": "6.0.0",
"gulp-if": "3.0.0",
Expand All @@ -76,6 +76,7 @@
"lazypipe": "1.0.2",
"lerna": "3.19.0",
"mini-css-extract-plugin": "0.8.0",
"parse-github-url": "1.0.2",
"postcss-import": "12.0.1",
"postcss-inline-svg": "4.1.0",
"postcss-lh": "2.0.2",
Expand Down
43 changes: 43 additions & 0 deletions packages/docs/.storybook/deploy.js
@@ -0,0 +1,43 @@
const ghpages = require('gh-pages');
const Git = require('gh-pages/lib/git');
const parse = require('parse-github-url');

const git = new Git(process.cwd(), 'git');
const metadata = require('../package.json');

const main = async () => {
try {
console.log('Determining origin url');
const origin = await git.getRemoteUrl('origin');

const { host, repo } = parse(origin);
const url = `https://${process.env.GITHUB_TOKEN}@${host}/${repo}`;

console.log(`Publishing documentation to ${url} gh-pages branch`);
await new Promise((resolve, reject) => {
ghpages.publish(
'dist',
{
repo: url,
message: `chore(release): documentation v${metadata.version}`,
},
err => {
if (err) reject(err);
resolve();
},
);
});
} catch (err) {
console.error(err);
throw err;
}
};

main()
.then(() => {
console.log(`Sucessfully published documentation to GitHub Pages`);
})
.catch(() => {
console.error(`Failed to publish documentation to GitHub Pages`);
process.exit(1);
});
7 changes: 2 additions & 5 deletions packages/docs/package.json
Expand Up @@ -24,13 +24,10 @@
"url": "https://github.com/swiftwork"
}
],
"storybook-deployer": {
"gitUsername": "GitHub Action",
"gitEmail": "action@github.com"
},
"scripts": {
"docs": "start-storybook --quiet -p 2999",
"docs:deploy": "storybook-to-ghpages"
"docs:build": "build-storybook -o dist --quiet",
"docs:deploy": "npm run docs:build && node .storybook/deploy.js"
},
"dependencies": {
"@trutoo/ui-core": "^1.4.5",
Expand Down

0 comments on commit 3e4468f

Please sign in to comment.