Align release and publish automation #57
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 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| checks: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9.14.2 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - run: pnpm install --frozen-lockfile | |
| - run: pnpm run check-types | |
| - name: Run tests for changed codemods | |
| shell: bash | |
| env: | |
| BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_SHA: ${{ github.sha }} | |
| run: | | |
| if [ "$EVENT_NAME" != "pull_request" ]; then | |
| pnpm run test | |
| exit 0 | |
| fi | |
| changed_paths=$(git diff --name-only "$BASE_SHA" "$HEAD_SHA") | |
| if echo "$changed_paths" | grep -qE '^(package\.json|pnpm-lock\.yaml|pnpm-workspace\.yaml|\.github/workflows/ci\.yml)$'; then | |
| pnpm run test | |
| exit 0 | |
| fi | |
| filters=$( | |
| echo "$changed_paths" \ | |
| | grep '^codemods/' \ | |
| | cut -d/ -f1-2 \ | |
| | sort -u \ | |
| | sed 's|^|--filter ./|' || true | |
| ) | |
| if [ -z "$filters" ]; then | |
| echo "No codemod packages affected; skipping tests." | |
| exit 0 | |
| fi | |
| # shellcheck disable=SC2086 | |
| pnpm $filters test |