|
11 | 11 |
|
12 | 12 | jobs: |
13 | 13 | check-main-override: |
14 | | - runs-on: ubuntu-latest |
15 | | - steps: |
16 | | - - name: 🛑 Block direct pushes to main (unless override flag) |
17 | | - run: | |
18 | | - echo "🔍 Checking push context: ${{ github.event_name }} → ${{ github.ref }}" |
19 | | - if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then |
20 | | - if [[ "${{ github.event.head_commit.message }}" != *"[override-main]"* ]]; then |
21 | | - echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." |
22 | | - exit 1 |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: 🛑 Block direct pushes to main (unless override flag) |
| 17 | + run: | |
| 18 | + echo "🔍 Event: ${{ github.event_name }} | Ref: ${{ github.ref }}" |
| 19 | + if [[ "${{ github.event_name }}" == "push" && "${{ github.ref }}" == "refs/heads/main" ]]; then |
| 20 | + COMMIT_MSG="${{ github.event.head_commit.message }}" |
| 21 | + echo "🔍 Commit message: $COMMIT_MSG" |
| 22 | + if [[ "$COMMIT_MSG" != *"[override-main]"* ]]; then |
| 23 | + echo "❌ Direct push to main is blocked. Use a PR or include [override-main] in your commit message." |
| 24 | + exit 1 |
| 25 | + else |
| 26 | + echo "✅ Override flag found. Proceeding." |
| 27 | + fi |
23 | 28 | else |
24 | | - echo "✅ Override flag found. Allowing push to main." |
| 29 | + echo "ℹ️ Not a direct push to main. Proceeding." |
25 | 30 | fi |
26 | | - else |
27 | | - echo "ℹ️ Not a direct push to main. Skipping protection." |
28 | | - fi |
29 | 31 |
|
30 | 32 | lint: |
31 | 33 | name: 🔍 Lint |
32 | 34 | runs-on: ubuntu-latest |
33 | | - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' |
34 | | - needs: [check-main-override] |
| 35 | + needs: check-main-override |
35 | 36 | steps: |
36 | 37 | - uses: actions/checkout@v4 |
37 | 38 | - uses: actions/setup-node@v4 |
38 | 39 | with: |
39 | 40 | node-version: 22 |
40 | 41 | cache: yarn |
41 | | - |
42 | | - - name: 📦 Install dependencies |
43 | | - run: yarn install --frozen-lockfile |
44 | | - |
45 | | - - name: Run Linter |
46 | | - run: yarn lint |
| 42 | + - run: yarn install --frozen-lockfile |
| 43 | + - run: yarn lint |
47 | 44 |
|
48 | 45 | typecheck: |
49 | 46 | name: ✅ Type Check |
50 | 47 | runs-on: ubuntu-latest |
51 | | - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' |
52 | | - needs: [check-main-override] |
| 48 | + needs: check-main-override |
53 | 49 | steps: |
54 | 50 | - uses: actions/checkout@v4 |
55 | 51 | - uses: actions/setup-node@v4 |
56 | 52 | with: |
57 | 53 | node-version: 22 |
58 | 54 | cache: yarn |
59 | | - |
60 | | - - name: 📦 Install dependencies |
61 | | - run: yarn install --frozen-lockfile |
62 | | - |
63 | | - - name: Run TypeScript |
64 | | - run: yarn typecheck |
| 55 | + - run: yarn install --frozen-lockfile |
| 56 | + - run: yarn typecheck |
65 | 57 |
|
66 | 58 | build: |
67 | 59 | name: 🔨 Build |
68 | 60 | runs-on: ubuntu-latest |
69 | | - if: github.ref != 'refs/heads/main' || github.event_name != 'push' || needs.check-main-override.result == 'success' |
70 | | - needs: [check-main-override] |
| 61 | + needs: check-main-override |
71 | 62 | steps: |
72 | 63 | - uses: actions/checkout@v4 |
73 | 64 | - uses: actions/setup-node@v4 |
74 | 65 | with: |
75 | 66 | node-version: 22 |
76 | 67 | cache: yarn |
77 | | - |
78 | | - - name: 📦 Install dependencies |
79 | | - run: yarn install --frozen-lockfile |
80 | | - |
| 68 | + - run: yarn install --frozen-lockfile |
81 | 69 | - name: ⚡ Cache .next build |
82 | 70 | uses: actions/cache@v4 |
83 | 71 | with: |
84 | 72 | path: .next |
85 | 73 | key: next-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} |
86 | 74 | restore-keys: | |
87 | 75 | next-${{ runner.os }}- |
88 | | -
|
89 | | - - name: Build App |
90 | | - run: yarn build |
| 76 | + - run: yarn build |
0 commit comments