diff --git a/.github/workflows/deploy-docsite.yml b/.github/workflows/deploy-docsite.yml index d2a5237be3..72c6973c08 100644 --- a/.github/workflows/deploy-docsite.yml +++ b/.github/workflows/deploy-docsite.yml @@ -1,4 +1,6 @@ -name: Deploy Docsite and Storybook +name: Docsite and Storybook CI/CD + +run-name: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'Build and Deploy' || 'Test Build' }} Docsite and Storybook env: NODE_VERSION: 20 @@ -7,9 +9,17 @@ on: push: branches: - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on workflow_dispatch: + # Also run any time a PR is opened targeting the docs or storybook resources + pull_request: + branches: + - main + paths: + - "docs/**" + - "storybook/**" + - "**/*.story.*" + - "**/*.stories.*" + - ".github/workflows/deploy-docsite.yml" jobs: build: @@ -37,11 +47,15 @@ jobs: - name: Copy Storybook to docs run: cp -r storybook-static docs/build/storybook && cp -r assets docs/build/assets/assets - name: Upload Build Artifact + # Only upload the build artifact when pushed to the main branch + if: github.event_name == 'push' && github.ref == 'refs/heads/main' uses: actions/upload-pages-artifact@v3 with: path: docs/build deploy: name: Deploy to GitHub Pages + # Only deploy when pushed to the main branch + if: github.event_name == 'push' && github.ref == 'refs/heads/main' needs: build # Grant GITHUB_TOKEN the permissions required to make a Pages deployment permissions: diff --git a/.github/workflows/test-build-docsite.yml b/.github/workflows/test-build-docsite.yml deleted file mode 100644 index 32f0e17d3e..0000000000 --- a/.github/workflows/test-build-docsite.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Test Docsite and Storybook Build - -env: - NODE_VERSION: 20 - -on: - pull_request: - branches: - - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on - paths: - - "docs/**" - - "storybook/**" - - "**/*.story.*" - - "**/*.stories.*" -jobs: - test-deploy: - name: Test deployment - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - uses: actions/setup-node@v4 - with: - node-version: ${{env.NODE_VERSION}} - - name: Install yarn - run: | - corepack enable - yarn install - - name: Test build website - run: yarn build - working-directory: docs/ - - name: Test build storybook - run: yarn build-storybook