Skip to content

Commit

Permalink
feat(*): post storybook url to PR after push (#39)
Browse files Browse the repository at this point in the history
* feat(*): post storybook url to PR after push

* fix(*): fix main workflow

* fix(*): update main workflow
  • Loading branch information
reme3d2y committed Mar 20, 2020
1 parent bac5a3b commit 9acc8ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,29 @@ jobs:
# run: yarn test

- name: Run build
id: demo_build
run: node ./bin/demo-build.js

- name: Publish storybook
run: |
cd ./storybook-demo
git push -q -f "https://alfa-bot:${{ secrets.BOT_AUTH_TOKEN }}@github.com/alfa-laboratory/core-components.git" master:gh-pages
# Ищем открытый PR
- name: Find open PR
uses: jwalton/gh-find-current-pr@v1
id: find_pr
with:
github-token: ${{ secrets.BOT_AUTH_TOKEN }}

# Если нашли открытый PR, то добавляем коммент с ссылкой на демку.
# storybook_url заполняется в demo-build.js
- name: Create comment
if: success() && steps.find_pr.outputs.number
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.BOT_AUTH_TOKEN }}
issue-number: ${{ steps.find_pr.outputs.pr }}
body: |
Собрана новая [демка](${{ steps.demo_build.outputs.storybook_url }}).
reaction-type: 'rocket'
11 changes: 6 additions & 5 deletions bin/demo-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ shell.exec('git add .', execOptions);
shell.exec(`git commit -m "${defaultConfig.commitMessage}"`, execOptions);

// log output url
if (sourceBranch === 'master') {
console.log(`=> Storybook deployed to: ${gitPagesUrl}/master/`);
} else {
console.log(`=> Storybook deployed to: ${gitPagesUrl}/${tempOutputDir}/`);
}
const storybookUrl = `${gitPagesUrl}/${sourceBranch === 'master' ? 'master' : tempOutputDir}/`;

console.log(`=> Storybook deployed to: ${storybookUrl}`);

// store storybook url
shell.exec(`echo ::set-output name=storybook_url::${storybookUrl}`);

0 comments on commit 9acc8ab

Please sign in to comment.