Merge pull request #7 from hoodieshq/dev #1
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: | |
| pull_request: | |
| push: | |
| branches: ["main"] | |
| jobs: | |
| changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| backend: ${{ steps.changes.outputs.backend }} | |
| frontend: ${{ steps.changes.outputs.frontend }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| if [ "${{ github.event_name }}" == "pull_request" ]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
| else | |
| BASE_SHA="${{ github.event.before }}" | |
| HEAD_SHA="${{ github.sha }}" | |
| fi | |
| # Check if backend files changed | |
| if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "^backend/"; then | |
| echo "backend=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "backend=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Check if frontend files changed | |
| if git diff --name-only "$BASE_SHA" "$HEAD_SHA" | grep -q "^frontend/"; then | |
| echo "frontend=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "frontend=false" >> $GITHUB_OUTPUT | |
| fi | |
| backend-check: | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: ${{ needs.changes.outputs.backend == 'true' }} | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Run format check | |
| run: make fmt-check | |
| frontend-check: | |
| runs-on: ubuntu-latest | |
| needs: changes | |
| if: ${{ needs.changes.outputs.frontend == 'true' }} | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| NEXT_TELEMETRY_DISABLED: 1 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Get pnpm version from package.json | |
| id: pnpm-version | |
| run: | | |
| echo "version=$(cat package.json | jq -r .packageManager | cut -d@ -f2)" >> $GITHUB_OUTPUT | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: ${{ steps.pnpm-version.outputs.version }} | |
| run_install: false | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: "pnpm" | |
| cache-dependency-path: "./frontend/pnpm-lock.yaml" | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Lint and format | |
| run: | | |
| pnpm format | |
| pnpm lint | |
| - name: Build project | |
| run: pnpm build |