Skip to content

Version Packages

Version Packages #381

Workflow file for this run

name: Publish Preview Package
on:
pull_request:
branches:
- "**"
types:
- opened
- synchronize
- reopened
paths:
- "packages/**"
- "package.json"
- ".github/workflows/pkg-pr-new.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
paths-filter:
name: Filter Changed Packages (Publish Preview Package)
runs-on: ubuntu-24.04
permissions:
pull-requests: read
timeout-minutes: 5
outputs:
eslint: ${{ steps.filter.outputs.eslint-config }}
prettier: ${{ steps.filter.outputs.prettier-config }}
stylelint: ${{ steps.filter.outputs.stylelint-config }}
tsconfig: ${{ steps.filter.outputs.tsconfig }}
directory: ${{ steps.filter.outputs.changes }}
steps:
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
# package.json を含めているのはl、ビルド環境が変わった場合にすべてのパッケージをビルドするようにするため
filters: |
eslint-config:
- 'packages/eslint-config/**'
- 'package.json'
prettier-config:
- 'packages/prettier-config/**'
- 'package.json'
stylelint-config:
- 'packages/stylelint-config/**'
- 'package.json'
tsconfig:
- 'packages/tsconfig/**'
- 'package.json'
publish:
name: Publish to pkg-pr-new (Publish Preview Package)
needs: paths-filter
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Setup Node.js and pnpm
uses: ./.github/common/setup-node-pnpm
- if: ${{ needs.paths-filter.outputs.eslint == 'true' }}
name: Build ESLint Config Package
run: pnpm build:eslint
- if: ${{ needs.paths-filter.outputs.prettier == 'true' }}
name: Build Prettier Config Package
run: pnpm build:prettier
- if: ${{ needs.paths-filter.outputs.stylelint == 'true' }}
name: Build Stylelint Config Package
run: pnpm build:stylelint
- if: ${{ needs.paths-filter.outputs.eslint == 'true' || needs.paths-filter.outputs.prettier == 'true' || needs.paths-filter.outputs.stylelint == 'true' || needs.paths-filter.outputs.tsconfig == 'true' }}
name: Publish Preview Package
shell: bash
# needs.paths-filter.outputs.directory には eslint-config | prettier-config | stylelint-config | tsconfig を要素とするJSON配列の文字列が入っている
# が、"["eslint-config","prettier-config","stylelint-config","tsconfig"]" のようになっているため、無理やり文字列にして直したあとにjqでパースする
run: |
RAW_DIRS="${{ needs.paths-filter.outputs.directory }}"
read -ra PACKAGE_DIRS < <(jq -r -c 'split(",") | map("./packages/" + .) | join(" ")' <<<"\"${RAW_DIRS:1:-1}\"")
pnpm run pkg-pr-new "${PACKAGE_DIRS[@]}"