Update CI/CD workflow to trigger releases on labeled pull requests #3
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: CI/CD | |
| on: | |
| push: | |
| pull_request: | |
| types: [labeled] | |
| env: | |
| CI: true | |
| COREPACK_INTEGRITY_KEYS: 0 | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| test: | |
| name: Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Enable corepack (for pnpm) | |
| run: corepack enable | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| cache: 'pnpm' | |
| node-version-file: '.nvmrc' | |
| - name: Install Node.js dependencies with pnpm | |
| run: > | |
| pnpm install | |
| --frozen-lockfile | |
| - name: Build | |
| run: pnpm prep | |
| - name: Type check | |
| run: pnpm check | |
| - name: Format check | |
| run: pnpm format | |
| - name: Check for pending changes | |
| run: | | |
| if git diff --exit-code; then | |
| echo "There are pending changes in git" | |
| exit 1 | |
| fi | |
| - name: Run tests | |
| run: pnpm test run --coverage | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: | | |
| (github.event_name == 'push' && !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')) || | |
| (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'release')) | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 'Set git user' | |
| run: | | |
| git config --global user.name 'storybook-bot' | |
| git config --global user.email '[email protected]' | |
| - name: Enable corepack (for pnpm) | |
| run: corepack enable | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| cache: 'pnpm' | |
| node-version-file: '.nvmrc' | |
| - name: Install Node.js dependencies with pnpm | |
| run: | | |
| pnpm install --frozen-lockfile | |
| - name: Build | |
| run: pnpm prep | |
| - name: Create Release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
| NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| run: | | |
| pnpm run release |