From f8878f5836eaa4e66c566dbf10061b4c57243f43 Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Mon, 13 May 2024 11:44:45 +0100 Subject: [PATCH 1/3] Update actions and attempt to fix fork workflow (#3400) --- .github/workflows/build-storybook.yml | 28 ++++++++ .github/workflows/chromatic.yml | 28 ++++---- .github/workflows/publish-storybook.yml | 92 +++++++++++++++++++++++++ .github/workflows/release.yml | 3 +- .github/workflows/snapshot.yml | 8 +-- .github/workflows/storybook-preview.yml | 76 -------------------- .github/workflows/test.yml | 10 +-- package.json | 2 +- yarn.lock | 18 +++-- 9 files changed, 159 insertions(+), 106 deletions(-) create mode 100644 .github/workflows/build-storybook.yml create mode 100644 .github/workflows/publish-storybook.yml delete mode 100644 .github/workflows/storybook-preview.yml diff --git a/.github/workflows/build-storybook.yml b/.github/workflows/build-storybook.yml new file mode 100644 index 00000000000..35706d77039 --- /dev/null +++ b/.github/workflows/build-storybook.yml @@ -0,0 +1,28 @@ +name: "Build Storybook" +on: + push: + branches: + - main + pull_request: + +jobs: + build-storybook: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "yarn" + - name: Install dependencies + run: yarn + - name: Build Storybook + run: yarn build-storybook + env: + NODE_OPTIONS: "--max_old_space_size=6144" + - uses: actions/upload-artifact@v4 + with: + name: storybook-build + path: ./storybook-static diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 702d5aa83db..16b76e5fd06 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -1,11 +1,10 @@ name: "Chromatic" on: - pull_request: - types: [opened, synchronize, reopened, ready_for_review] - push: - branches: - - main + workflow_run: + workflows: ["Build Storybook"] + types: + - completed jobs: chromatic-deployment: @@ -17,19 +16,21 @@ jobs: with: fetch-depth: 0 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" - name: Install dependencies run: yarn - - name: Build ag grid theme - run: yarn build:ag-grid-theme - - name: Bundle css - run: yarn bundle:css - # 👇 Adds Chromatic as a step in the workflow + - name: "Download build artifact" + uses: actions/download-artifact@v4 + with: + name: storybook-build + path: ./storybook-static + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} - name: Publish to Chromatic - uses: chromaui/action-next@v1 + uses: chromaui/action@v1 # Chromatic GitHub Action options with: # 👇 Chromatic projectToken, refer to the manage page to obtain it. @@ -42,5 +43,4 @@ jobs: autoAcceptChanges: "main" ignoreLastBuildOnBranch: "!(main)**" traceChanged: "expanded" - env: - NODE_OPTIONS: "--max_old_space_size=6144" + storybookBuildDir: "./storybook-static" diff --git a/.github/workflows/publish-storybook.yml b/.github/workflows/publish-storybook.yml new file mode 100644 index 00000000000..5c340d15d22 --- /dev/null +++ b/.github/workflows/publish-storybook.yml @@ -0,0 +1,92 @@ +name: Storybook Preview Publish + +on: + workflow_run: + workflows: ["Build Storybook"] + types: + - completed + +jobs: + deploy: + runs-on: ubuntu-latest + + permissions: + contents: read + deployments: write + pull-requests: write + statuses: write + + name: Deploy Storybook to Cloudflare Pages + steps: + - name: Set initial commit status + uses: actions/github-script@v7 + with: + script: | + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: "${{ github.event.workflow_run.head_commit.id }}", + state: "pending", + description: "Pending", + context: "Storybook" + }) + - name: Checkout + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: "20" + cache: "yarn" + + - name: Install dependencies + run: yarn + + - name: "Download build artifact" + uses: actions/download-artifact@v4 + with: + name: storybook-build + path: ./storybook-static + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Publish + uses: cloudflare/pages-action@v1 + id: publish + with: + apiToken: ${{ secrets.CLOUDFLARE_SALT_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_SALT_ACCOUNT_ID }} + projectName: "saltdesignsystem-storybook" + directory: ./storybook-static + gitHubToken: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.head_ref || github.ref_name }} + + - name: Update deploy status (success) + uses: actions/github-script@v7 + if: success() && github.event.workflow_run.event == 'pull_request' + with: + script: | + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: "${{ github.event.workflow_run.head_commit.id }}", + state: "sucesss", + description: "Successfully deployed", + context: "Storybook" + target_url: "${{ steps.publish.outputs.url }}" + }); + + - name: Update deploy status (failure) + uses: actions/github-script@v7 + if: failure() && github.event.workflow_run.event == 'pull_request' + with: + script: | + await github.rest.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: "${{ github.event.workflow_run.head_commit.id }}", + state: "error", + description: "Failed to deploy", + context: "Storybook" + target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" + }); diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6cd7c69a55c..9eba09ea8ad 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,12 +14,13 @@ permissions: jobs: release: name: Release + if: github.repository == 'jpmorganchase/salt-ds' runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 98c7ae0fbc3..1b262830d98 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -19,7 +19,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Enforce write permissions - uses: actions/github-script@v6 + uses: actions/github-script@v7 env: COMMENT_ID: ${{ github.event.comment.id }} with: @@ -49,7 +49,7 @@ jobs: ) } - name: Validate pull request - uses: actions/github-script@v6 + uses: actions/github-script@v7 id: pr_data env: FORK: ${{ github.event.pull_request.head.repo.fork }} @@ -76,7 +76,7 @@ jobs: ref: refs/pull/${{ github.event.issue.number }}/head - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -85,7 +85,7 @@ jobs: - name: Install dependencies run: yarn install - name: Create and publish snapshot release - uses: actions/github-script@v6 + uses: actions/github-script@v7 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} COMMENT_ID: ${{ github.event.comment.id }} diff --git a/.github/workflows/storybook-preview.yml b/.github/workflows/storybook-preview.yml deleted file mode 100644 index a87a4967455..00000000000 --- a/.github/workflows/storybook-preview.yml +++ /dev/null @@ -1,76 +0,0 @@ -name: Storybook Preview Publish - -on: - workflow_dispatch: - pull_request: - -jobs: - deploy: - runs-on: ubuntu-latest - - permissions: - contents: read - deployments: write - pull-requests: write - - name: Deploy to Cloudflare Pages - - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: "20" - cache: "yarn" - - - name: Install dependencies - run: yarn - - - name: Run build - run: yarn build-storybook - env: - NODE_OPTIONS: "--max_old_space_size=6144" - - - name: Publish - uses: cloudflare/pages-action@v1 - id: publish - with: - apiToken: ${{ secrets.CLOUDFLARE_SALT_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_SALT_ACCOUNT_ID }} - projectName: "saltdesignsystem-storybook" - directory: ./storybook-static - gitHubToken: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.head_ref || github.ref_name }} - - - name: Preview URL - uses: actions/github-script@v6 - with: - script: | - if (context.eventName == 'pull_request') { - const previewUrl = "${{ steps.publish.outputs.url }}"; - const commentText = `Storybook Preview Link `; - const {data: comments} = await github.rest.issues.listComments({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.payload.number, - }); - const oldPreviewUrlComment = comments.find(comment => comment.body.includes(commentText)); - if (!oldPreviewUrlComment) { - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `${commentText} ${previewUrl}` - }); - } else { - github.rest.issues.updateComment({ - comment_id: oldPreviewUrlComment.id, - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `${commentText} ${previewUrl}` - }); - }; - } diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 47ed00bb86f..caa99cf5e19 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,7 +13,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -40,7 +40,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -72,7 +72,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -85,7 +85,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" @@ -102,7 +102,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Use Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: "20" cache: "yarn" diff --git a/package.json b/package.json index e317eecbc1a..a7575977c0a 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "ag-grid-enterprise": "^28.2.1", "ag-grid-react": "^28.2.1", "axe-core": "^4.9.0", - "chromatic": "^10.2.0", + "chromatic": "^11.3.2", "ci-info": "^3.3.1", "clsx": "^2.0.0", "cypress": "^13.8.0", diff --git a/yarn.lock b/yarn.lock index 8b162c4b5b5..c7f36521cd9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6284,7 +6284,7 @@ __metadata: ag-grid-enterprise: "npm:^28.2.1" ag-grid-react: "npm:^28.2.1" axe-core: "npm:^4.9.0" - chromatic: "npm:^10.2.0" + chromatic: "npm:^11.3.2" ci-info: "npm:^3.3.1" clsx: "npm:^2.0.0" cypress: "npm:^13.8.0" @@ -12553,14 +12553,22 @@ __metadata: languageName: node linkType: hard -"chromatic@npm:^10.2.0": - version: 10.2.0 - resolution: "chromatic@npm:10.2.0" +"chromatic@npm:^11.3.2": + version: 11.3.2 + resolution: "chromatic@npm:11.3.2" + peerDependencies: + "@chromatic-com/cypress": ^0.*.* || ^1.0.0 + "@chromatic-com/playwright": ^0.*.* || ^1.0.0 + peerDependenciesMeta: + "@chromatic-com/cypress": + optional: true + "@chromatic-com/playwright": + optional: true bin: chroma: dist/bin.js chromatic: dist/bin.js chromatic-cli: dist/bin.js - checksum: 10/8df1b4a828c7d5eb2614fcab9a1685f5be947a68f5f31733ebf2bbfab86f6b02c0ee99064bfe62b1457f05ddef285c1d36d5674208f778c815714c51c72a68bd + checksum: 10/2537b86eb5799be7ddab81544699cab98c01629c5e65d59d869beac7c15aee046520f1ae63decd889146e2ec67d1d12e6589424702ea9216d226e2dff6bf04db languageName: node linkType: hard From 24d997dca56a75010ce4bf18b15821f41fc37cd7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 13 May 2024 12:04:54 +0100 Subject: [PATCH 2/3] Update chromaui/action action to v11 (#3405) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- .github/workflows/chromatic.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/chromatic.yml b/.github/workflows/chromatic.yml index 16b76e5fd06..7c1cccf2371 100644 --- a/.github/workflows/chromatic.yml +++ b/.github/workflows/chromatic.yml @@ -30,7 +30,7 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} run-id: ${{ github.event.workflow_run.id }} - name: Publish to Chromatic - uses: chromaui/action@v1 + uses: chromaui/action@v11 # Chromatic GitHub Action options with: # 👇 Chromatic projectToken, refer to the manage page to obtain it. From 90fefe52026d6f1e63bf09d57656ae7752d7542d Mon Sep 17 00:00:00 2001 From: Josh Wooding <12938082+joshwooding@users.noreply.github.com> Date: Mon, 13 May 2024 12:40:10 +0100 Subject: [PATCH 3/3] Fix SB publish (#3406) --- .github/workflows/publish-storybook.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-storybook.yml b/.github/workflows/publish-storybook.yml index 5c340d15d22..3b9da681e16 100644 --- a/.github/workflows/publish-storybook.yml +++ b/.github/workflows/publish-storybook.yml @@ -72,7 +72,7 @@ jobs: sha: "${{ github.event.workflow_run.head_commit.id }}", state: "sucesss", description: "Successfully deployed", - context: "Storybook" + context: "Storybook", target_url: "${{ steps.publish.outputs.url }}" }); @@ -87,6 +87,6 @@ jobs: sha: "${{ github.event.workflow_run.head_commit.id }}", state: "error", description: "Failed to deploy", - context: "Storybook" + context: "Storybook", target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" });