diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 3ecee0825..69d548cf7 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -2,7 +2,7 @@ name: Generate new release on: push: tags: - - 'v5*' + - "v5*" jobs: build: runs-on: ubuntu-latest @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 20 - registry-url: 'https://registry.npmjs.org' + registry-url: "https://registry.npmjs.org" - name: git config run: | git config user.name "${GITHUB_ACTOR}" @@ -30,15 +30,8 @@ jobs: run: yarn --silent extract-changelog-release > RELEASE_BODY.md - uses: ncipollo/release-action@v1 with: - bodyFile: 'RELEASE_BODY.md' + bodyFile: "RELEASE_BODY.md" token: ${{ secrets.GITHUB_TOKEN }} - - name: Publish on gh-pages - run: | - git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - yarn storybook:build - yarn storybook:deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - uses: italia/slack-notify-release-action@v0.4.0 with: slack_token: ${{ secrets.SLACK_TOKEN }} diff --git a/.github/workflows/update-docs.yml b/.github/workflows/update-docs.yml index f4b80dc0a..ca660439b 100644 --- a/.github/workflows/update-docs.yml +++ b/.github/workflows/update-docs.yml @@ -2,32 +2,82 @@ name: Update documentation on: workflow_dispatch: + push: + tags: + - "v5*" + +permissions: {} jobs: deploy: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: fetch-depth: 0 + persist-credentials: false + - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 with: - node-version: '20.x' + node-version: 20 + package-manager-cache: false + - name: Git config run: | git config user.name "${GITHUB_ACTOR}" git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + - name: Install dependencies run: yarn - - name: Build documentation + + - name: Build docs + run: yarn storybook:build + + - name: Extract destination folder name run: | - yarn build - - name: Publish on gh-pages + if [[ "${GITHUB_REF_TYPE}" == "tag" ]]; then + if [[ "${GITHUB_REF_NAME}" =~ ^v5\.[0-9]+\.[0-9]+$ ]]; then + echo "DEST_FOLDER=${GITHUB_REF_NAME}" >> $GITHUB_ENV + else + echo "Invalid tag format: ${GITHUB_REF_NAME}. Expected v5.." >&2 + exit 1 + fi + else + echo "DEST_FOLDER=latest" >> $GITHUB_ENV + fi + + - name: Deploy docs + uses: peaceiris/actions-gh-pages@47f197a2200bb9de68ba5f48fad1c088eb1c4a32 # v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./storybook-static + destination_dir: ${{ env.DEST_FOLDER }} # Subfolder name to deploy docs into + keep_files: false # Clear previous docs in destination subfolder to avoid orphaned files + + - name: Create root redirect to latest run: | - git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git - yarn storybook:build - yarn storybook:deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + mkdir -p /tmp/root + cat > /tmp/root/index.html << 'REDIRECT' + + + + + + + + +

Redirecting to latest documentation...

+ + + REDIRECT + + - name: Deploy root redirect + uses: peaceiris/actions-gh-pages@47f197a2200bb9de68ba5f48fad1c088eb1c4a32 # v4.0.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: /tmp/root + keep_files: true diff --git a/.storybook/main.ts b/.storybook/main.ts index c66101267..3b5ce24a8 100644 --- a/.storybook/main.ts +++ b/.storybook/main.ts @@ -18,6 +18,7 @@ const config: StorybookConfig = { return mergeConfig(config, { // Add dependencies to pre-optimization + base: './', build: { chunkSizeWarningLimit: 1000, minify: false diff --git a/package.json b/package.json index dd5a84e75..34fad7433 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,6 @@ "storybook:serve": "storybook dev -p 9001", "storybook:build": "storybook build --docs", "storybook:build:base": "storybook build", - "storybook:deploy": "npx gh-pages -d storybook-static -m 'chore: update documentation [ci skip]' --nojekyll", "version": "conventional-changelog -p angular -i CHANGELOG.md -s && node scripts/wait-confirm && git add CHANGELOG.md", "postversion": "echo \"You can now publish your version using 'git push --follow-tags'\"" },