|
29 | 29 |
|
30 | 30 | jobs: |
31 | 31 | prettier: |
32 | | - name: Prettier Code Format Validation |
| 32 | + name: 💅 Prettier Code Format Validation |
33 | 33 | runs-on: ubuntu-latest |
34 | 34 |
|
35 | 35 | steps: |
36 | 36 | - name: 📦 Checkout Repository |
37 | | - uses: actions/checkout@v4.2.2 |
| 37 | + uses: actions/checkout@v4.1.1 |
38 | 38 |
|
39 | 39 | - name: ⚙️ Setup Node.js |
40 | | - uses: actions/setup-node@v4.0.3 |
| 40 | + uses: actions/setup-node@v4 |
41 | 41 | with: |
42 | 42 | node-version: '20' |
43 | 43 | cache: 'npm' |
44 | 44 |
|
45 | | - - name: 📦 Install Dependencies from Lockfile |
| 45 | + - name: 📥 Install Dependencies from Lockfile |
46 | 46 | run: npm ci |
47 | 47 |
|
48 | 48 | - name: 🔍 Run Prettier Check |
49 | 49 | id: prettier |
50 | 50 | run: | |
51 | | - npx prettier --check . > prettier-report.txt || true |
| 51 | + echo "Running Prettier..." |
| 52 | + npx prettier --check . > prettier-report.txt 2>&1 || true |
52 | 53 |
|
53 | | - - name: 📊 Upload Prettier Report |
54 | | - if: failure() |
| 54 | + - name: 📄 Generate GitHub Job Summary |
| 55 | + shell: bash |
| 56 | + run: | |
| 57 | + if grep -q "Code style issues found" prettier-report.txt; then |
| 58 | + echo "### 💅 Prettier Format Summary" >> $GITHUB_STEP_SUMMARY |
| 59 | + echo "❌ Code style issues detected. See artifact report for details." >> $GITHUB_STEP_SUMMARY |
| 60 | + else |
| 61 | + echo "### 💅 Prettier Format Summary" >> $GITHUB_STEP_SUMMARY |
| 62 | + echo "✅ No formatting issues found." >> $GITHUB_STEP_SUMMARY |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: 📊 Upload Prettier Report Artifact |
55 | 66 | uses: actions/upload-artifact@v4 |
56 | 67 | with: |
57 | | - name: prettier-report |
| 68 | + name: prettier-format-report |
58 | 69 | path: prettier-report.txt |
59 | 70 | retention-days: 7 |
60 | | - |
| 71 | + |
| 72 | + - name: 💥 Fail if Prettier Violations Exist |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + if grep -q "Code style issues found" prettier-report.txt; then |
| 76 | + echo "❌ Failing due to Prettier formatting violations." |
| 77 | + exit 1 |
| 78 | + else |
| 79 | + echo "✅ No formatting issues. Passing." |
| 80 | + fi |
0 commit comments