Skip to content

Commit

Permalink
Separate docs workflow (#965)
Browse files Browse the repository at this point in the history
* Separate building the docs so that it can be manually run without also publishing the package.
* Call the publish docs workflow only if the NPM publish succeeds.
  • Loading branch information
huwshimi authored Aug 31, 2023
1 parent c4b8cd6 commit 3259eeb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 30 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/publish-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish docs

on:
workflow_call:
workflow_dispatch:

jobs:
build-docs:
name: Build Storybook docs
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Install dependencies
run: yarn install
- name: Build Storybook
run: yarn build-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "./docs"
publish-docs:
name: Publish to GitHub Pages
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
needs: build-docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
30 changes: 3 additions & 27 deletions .github/workflows/publish-on-release.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Publish to NPM and GitHub Pages
name: Publish to NPM

on:
release:
types: [published]
workflow_dispatch:

jobs:
publish-npm:
Expand All @@ -24,29 +23,6 @@ jobs:
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
build-docs:
runs-on: publish-npm
needs: build-docs
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build Storybook
run: yarn build-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "./docs"
publish-docs:
name: Publish to GitHub Pages
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
needs: build-docs
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
needs: publish-npm
uses: ./.github/workflows/publish-docs.yml
6 changes: 3 additions & 3 deletions PUBLISH-NPM-PACKAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
To publish a new react-components release you will need to [update the version](#update-package-version) in package.json and [create a new
release](#publish-the-release). Once the release has been created in GitHub the
package will automatically get built and published to NPM and the docs will get
redeployed (see [publish-on-release.yml](./.github/workflows/publish-on-release.yml)).
redeployed (see
[publish-on-release.yml](./.github/workflows/publish-on-release.yml) and [publish-docs.yml](./.github/workflows/publish-docs.yml)).

If needed, you can also [manually trigger the action](#manually-update-docs) to build the docs if you need this to happen without doing a release.

Expand Down Expand Up @@ -56,8 +57,7 @@ You should now see the new version on [NPM](https://www.npmjs.com/package/@canon
To rebuild the docs you need to manually trigger the publish action. More
details in the [GitHub docs](https://docs.github.com/en/actions/using-workflows/manually-running-a-workflow).

1. Go to the [Publish to NPM and GitHub
Pages](https://github.com/canonical/react-components/actions/workflows/publish-on-release.yml) action.
1. Go to the [Publish docs](https://github.com/canonical/react-components/actions/workflows/publish-docs.yml) action.
2. Click the 'Run workflow' button.
3. Select the `main`` branch.
4. Click 'Run workflow'.
Expand Down

0 comments on commit 3259eeb

Please sign in to comment.