|
| 1 | +name: PR Storybook - Preview |
| 2 | +run-name: "PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + branches: |
| 7 | + - 26_1 |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - reopened |
| 11 | + - synchronize |
| 12 | + - labeled |
| 13 | + - unlabeled |
| 14 | + - closed |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: write |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: preview-${{ github.event.pull_request.number }} |
| 21 | + cancel-in-progress: true |
| 22 | + |
| 23 | +env: |
| 24 | + SOURCE_DIR: ./apps/react-storybook/storybook-static |
| 25 | + |
| 26 | +jobs: |
| 27 | + deploy: |
| 28 | + name: Build & Deploy |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 20 |
| 31 | + if: >- |
| 32 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 33 | + ( |
| 34 | + (github.event.action == 'labeled' && github.event.label.name == 'storybook') || |
| 35 | + (github.event.action != 'labeled' && github.event.action != 'closed' && contains(github.event.pull_request.labels.*.name, 'storybook')) |
| 36 | + ) |
| 37 | + environment: |
| 38 | + name: storybook |
| 39 | + url: https://devexpress.github.io/DevExtreme/preview/pr-${{ github.event.pull_request.number }} |
| 40 | + |
| 41 | + steps: |
| 42 | + - name: Checkout repository |
| 43 | + uses: actions/checkout@v6 |
| 44 | + with: |
| 45 | + submodules: true |
| 46 | + fetch-depth: 1 |
| 47 | + |
| 48 | + - name: Use Node.js |
| 49 | + uses: actions/setup-node@v6 |
| 50 | + with: |
| 51 | + node-version-file: '.node-version' |
| 52 | + |
| 53 | + - name: Setup pnpm |
| 54 | + uses: pnpm/action-setup@v6 |
| 55 | + with: |
| 56 | + run_install: false |
| 57 | + |
| 58 | + - name: Get pnpm store directory |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Setup pnpm + nx cache |
| 64 | + uses: actions/cache@v5 |
| 65 | + with: |
| 66 | + path: | |
| 67 | + ${{ env.STORE_PATH }} |
| 68 | + .nx/cache |
| 69 | + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} |
| 70 | + restore-keys: | |
| 71 | + ${{ runner.os }}-pnpm-store |
| 72 | +
|
| 73 | + - name: Install dependencies |
| 74 | + run: pnpm install --frozen-lockfile |
| 75 | + |
| 76 | + - name: Build Storybook preview (static) |
| 77 | + run: pnpm nx build devextreme-react-storybook |
| 78 | + |
| 79 | + - name: Deploy PR preview |
| 80 | + uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1 |
| 81 | + with: |
| 82 | + action: deploy |
| 83 | + pr-number: ${{ github.event.pull_request.number }} |
| 84 | + source-dir: ${{ env.SOURCE_DIR }} |
| 85 | + preview-branch: gh-pages |
| 86 | + umbrella-dir: preview |
| 87 | + comment: false |
| 88 | + token: ${{ github.token }} |
| 89 | + wait-for-pages-deployment: true |
| 90 | + |
| 91 | + remove: |
| 92 | + name: Remove preview |
| 93 | + runs-on: ubuntu-latest |
| 94 | + timeout-minutes: 10 |
| 95 | + if: >- |
| 96 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 97 | + ( |
| 98 | + (github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'storybook')) || |
| 99 | + (github.event.action == 'unlabeled' && github.event.label.name == 'storybook') |
| 100 | + ) |
| 101 | +
|
| 102 | + steps: |
| 103 | + - name: Checkout repository |
| 104 | + uses: actions/checkout@v6 |
| 105 | + |
| 106 | + - name: Remove PR preview |
| 107 | + uses: rossjrw/pr-preview-action@ffa7509e91a3ec8dfc2e5536c4d5c1acdf7a6de9 # v1.8.1 |
| 108 | + with: |
| 109 | + action: remove |
| 110 | + pr-number: ${{ github.event.pull_request.number }} |
| 111 | + source-dir: ${{ env.SOURCE_DIR }} |
| 112 | + preview-branch: gh-pages |
| 113 | + umbrella-dir: preview |
| 114 | + comment: false |
| 115 | + token: ${{ github.token }} |
| 116 | + wait-for-pages-deployment: true |
0 commit comments