fix(Layout): fix panel header props type #2363
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pull Request | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths-ignore: | |
| - '.changeset/**' | |
| - '.husky/**' | |
| # Slash command trigger: comment `/publish-canary` on a PR | |
| issue_comment: | |
| types: [created] | |
| concurrency: | |
| group: ci-pull-request=${{github.ref}}-1 | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read # Read-only access to repository contents | |
| issues: write # Write access to issues | |
| pull-requests: write # Write access to pull requests | |
| statuses: write # Write access to commit statuses | |
| actions: write # Required to trigger workflows | |
| jobs: | |
| build: | |
| # Skip build for slash command triggers - we reuse the artifact from the original PR run | |
| if: github.event_name != 'issue_comment' | |
| name: 'Build' | |
| runs-on: ubuntu-latest | |
| env: | |
| NODE_OPTIONS: --max-old-space-size=4096 | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update Corepack | |
| run: npm i -g corepack@latest | |
| - name: Enable Corepack (pre) | |
| run: corepack enable | |
| - name: Prepare pnpm (pre) | |
| run: corepack prepare [email protected] --activate | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Prepare pnpm | |
| run: corepack prepare [email protected] --activate | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Set env | |
| run: echo "SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV | |
| - name: Increment canary | |
| run: npm version 0.0.0-canary-$SHORT_SHA --no-git-tag-version | |
| - name: Build project | |
| run: pnpm build | |
| - name: Get version | |
| id: version | |
| working-directory: ./dist | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Upload build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: dist | |
| path: ./dist | |
| retention-days: 7 | |
| trigger-publish: | |
| name: 'Trigger canary publish' | |
| # Runs only when someone comments `/publish-canary` on a PR (not an issue). | |
| if: >- | |
| github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && | |
| contains(github.event.comment.body, '/publish-canary') | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| actions: write | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Get PR details | |
| id: pr | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number | |
| }) | |
| core.setOutput('head_repo', pr.head.repo.full_name) | |
| core.setOutput('number', pr.number) | |
| return pr | |
| - name: Check if same-repo PR | |
| if: steps.pr.outputs.head_repo != github.repository | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `⚠️ Canary publish is not supported for fork PRs (security reasons).` | |
| }) | |
| core.setFailed('Fork PRs cannot trigger canary publish') | |
| - name: Check actor permission | |
| id: actor_permission | |
| if: steps.pr.outputs.head_repo == github.repository | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| result-encoding: string | |
| script: | | |
| if (context.actor === 'tenphi') { | |
| return 'allowed' | |
| } | |
| const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| username: context.actor | |
| }) | |
| // Values: none, read, triage, write, maintain, admin | |
| return data.permission | |
| - name: Reject unauthorized trigger | |
| if: steps.pr.outputs.head_repo == github.repository && steps.actor_permission.outputs.result != 'allowed' && steps.actor_permission.outputs.result != 'maintain' && steps.actor_permission.outputs.result != 'admin' | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body: `⚠️ Canary publish wasn't triggered because @${context.actor} is not allowed to run it. Only **tenphi** or repo **maintainers/admins** can trigger canary publishing.` | |
| }) | |
| core.setFailed('Unauthorized user') | |
| - name: Find latest successful build run | |
| id: find_run | |
| if: steps.pr.outputs.head_repo == github.repository && (steps.actor_permission.outputs.result == 'allowed' || steps.actor_permission.outputs.result == 'maintain' || steps.actor_permission.outputs.result == 'admin') | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| // Find the latest successful workflow run for this PR that has the 'dist' artifact | |
| const runs = await github.rest.actions.listWorkflowRuns({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'pull-request.yml', | |
| event: 'pull_request', | |
| status: 'success', | |
| per_page: 20 | |
| }) | |
| const prNumber = context.issue.number | |
| for (const run of runs.data.workflow_runs) { | |
| // Check if this run is associated with our PR | |
| if (run.pull_requests.some(pr => pr.number === prNumber)) { | |
| // Check if it has the dist artifact | |
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: run.id | |
| }) | |
| if (artifacts.data.artifacts.some(a => a.name === 'dist')) { | |
| core.setOutput('run_id', run.id) | |
| console.log(`Found run ${run.id} with dist artifact`) | |
| return | |
| } | |
| } | |
| } | |
| core.setFailed('No successful build run with dist artifact found for this PR. Please wait for the build to complete first.') | |
| - name: Trigger publish workflow | |
| if: steps.find_run.outputs.run_id | |
| uses: actions/github-script@v6 | |
| with: | |
| # Use a dedicated token (PAT or GitHub App token) if provided; otherwise fall back to the workflow token. | |
| github-token: ${{ secrets['WORKFLOW_TRIGGER_TOKEN'] || github.token }} | |
| script: | | |
| const prNumber = context.issue.number | |
| const runId = '${{ steps.find_run.outputs.run_id }}' | |
| await github.rest.repos.createDispatchEvent({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| event_type: 'publish-canary', | |
| client_payload: { | |
| pr_number: String(prNumber), | |
| run_id: runId | |
| } | |
| }) | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: `🚀 Triggered canary publish workflow using build from run [#${runId}](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}).` | |
| }) | |
| tests: | |
| name: 'Tests & lint' | |
| if: github.event_name != 'issue_comment' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update Corepack | |
| run: npm i -g corepack@latest | |
| - name: Enable Corepack (pre) | |
| run: corepack enable | |
| - name: Prepare pnpm (pre) | |
| run: corepack prepare [email protected] --activate | |
| - uses: actions/cache@v4 | |
| name: Download eslint cache | |
| with: | |
| path: | | |
| **/.eslintcache | |
| key: ${{ runner.os }}-eslint | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Prepare pnpm | |
| run: corepack prepare [email protected] --activate | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run the lint | |
| run: pnpm lint | |
| - name: Run the tests | |
| run: pnpm test:no-cache | |
| deploy-chromatic: | |
| name: 'Prepare Storybook for review & tests' | |
| if: github.event_name != 'issue_comment' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: Chromatic staging | |
| url: ${{ steps.publish_chromatic.outputs.url }} | |
| env: | |
| CHROMATIC_RETRIES: 5 | |
| LOG_LEVEL: 'error' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update Corepack | |
| run: npm i -g corepack@latest | |
| - name: Enable Corepack (pre) | |
| run: corepack enable | |
| - name: Prepare pnpm (pre) | |
| run: corepack prepare [email protected] --activate | |
| - uses: actions/cache@v4 | |
| name: Download storybook cache | |
| with: | |
| path: | | |
| **/node_modules/.cache | |
| key: ${{ runner.os }}-storybook-${{ github.run_id }} | |
| restore-keys: | | |
| ${{ runner.os }}-storybook | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Prepare pnpm | |
| run: corepack prepare [email protected] --activate | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Publish to Chromatic | |
| id: publish_chromatic | |
| uses: chromaui/action@v11 | |
| with: | |
| exitZeroOnChanges: true | |
| exitOnceUploaded: true | |
| onlyChanged: true | |
| debug: true | |
| token: ${{ github.token }} | |
| projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
| - name: Comment PR | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ github.token }} | |
| script: | | |
| const setMessage = require('${{ github.workspace }}/scripts/ci/set-message.cjs') | |
| await setMessage({ | |
| header: "## 🧪 Storybook is successfully deployed!", | |
| body: ` | |
| - 👀 Review changes: ${{ steps.publish_chromatic.outputs.url }} | |
| - 👨🎨 Preview storybook: ${{ steps.publish_chromatic.outputs.storybookUrl }} | |
| `, | |
| github, | |
| repo: context.repo, | |
| prNumber: context.payload.pull_request.number | |
| }) |