name: React - Build & Lint
on: workflow_call: inputs: runner: description: 'Runner type' required: false type: string default: 'ubuntu-latest' node_version: description: 'Node.js version' required: false type: string default: '24' package_manager: description: 'Package manager (npm or yarn)' required: false type: string default: 'yarn' build_command: description: 'Build script name (yarn <command>)' required: false type: string default: 'build' build_output_dir: description: 'Build output directory (build for CRA, dist for Vite)' required: false type: string default: 'build' run_lint: description: 'Run yarn lint' required: false type: boolean default: true run_type_check: description: 'Run yarn type-check (TypeScript projects)' required: false type: boolean default: false artifact_retention_days: description: 'Days to retain build artifact' required: false type: number default: 1
jobs: build: name: Build & Lint runs-on: ${{ inputs.runner }} timeout-minutes: 15
steps: - name: Checkout uses: actions/checkout@v5
- name: Setup Node.js ${{ inputs.node_version }} uses: actions/setup-node@v5 with: node-version: ${{ inputs.node_version }} cache: ${{ inputs.package_manager }}
- name: Install dependencies run: | if [ "${{ inputs.package_manager }}" = "yarn" ]; then yarn install --frozen-lockfile else npm ci fi
- name: Lint if: inputs.run_lint run: | if [ "${{ inputs.package_manager }}" = "yarn" ]; then yarn lint else npm run lint fi
- name: Type check if: inputs.run_type_check run: | if [ "${{ inputs.package_manager }}" = "yarn" ]; then yarn type-check else npm run type-check fi
- name: Build run: | if [ "${{ inputs.package_manager }}" = "yarn" ]; then yarn ${{ inputs.build_command }} else npm run ${{ inputs.build_command }} fi
- name: Upload build artifact uses: actions/upload-artifact@v5 with: name: build-output-${{ github.run_id }} path: ${{ inputs.build_output_dir }} retention-days: ${{ inputs.artifact_retention_days }} React· Reusable workflow ·on: workflow_call
React Build
React - Build & Lint
.github/workflows/react-build.yml