-
Notifications
You must be signed in to change notification settings - Fork 5
95 lines (81 loc) · 3.66 KB
/
code_formatting.yml
File metadata and controls
95 lines (81 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Code Formatting
on:
push:
# Hanya jalankan pada push ke branch utama (misalnya main atau master)
# Anda bisa menyesuaikannya
branches:
- dev
- temp
pull_request:
# Jalankan pada pull request untuk memastikan kode masuk sudah bersih
branches:
- dev
- temp
# permissions:
# contents: write # <--- TAMBAHKAN DI SINI
jobs:
format-code:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
# Penting: Checkout dengan kedalaman penuh agar bisa melakukan push balik jika ada perubahan
with:
fetch-depth: 0
# --- SETUP PHP & LARAVEL PINT ---
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
extensions: iconv, mbstring
coverage: none
# - name: Get Composer Cache Directory
# id: composer-cache
# run: echo "dir=$(composer config cache-dir)" >> $GITHUB_OUTPUT
# - name: Cache Composer dependencies
# uses: actions/cache@v4
# with:
# path: ${{ steps.composer-cache.outputs.dir }}
# key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
# restore-keys: ${{ runner.os }}-composer-
- name: Install Composer Dependencies
run: composer install --prefer-dist --no-progress
- name: 🎨 Run Laravel Pint (PHP Formatting)
run: ./vendor/bin/pint --test
continue-on-error: true
# Pint akan memformat file in-place
# --- SETUP NODE & PRETTIER ---
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Gunakan versi Node.js LTS terbaru
- name: 📦 Install Prettier
# Asumsi Anda menggunakan Prettier sebagai dev dependency (npm install --save-dev prettier)
# Jika tidak, ganti dengan: npm install -g prettier
run: npm install
- name: 💅 Run Prettier (HTML, CSS, JS, Blade Formatting)
run: npx prettier --check .
continue-on-error: true
# Perintah ini akan memformat semua file yang didukung oleh Prettier in-place
# --- COMMIT & PUSH BALIK PERUBAHAN ---
# - name: ⚙️ Check for changes and Commit
# id: git-check
# run: |
# if [ -n "$(git status --porcelain)" ]; then
# echo "changes_detected=true" >> $GITHUB_OUTPUT
# echo "::notice title=Formatting Changes::Changes detected after running formatters."
# else
# echo "changes_detected=false" >> $GITHUB_OUTPUT
# echo "::notice title=Formatting Clean::No formatting changes needed."
# fi
# - name: 📤 Push Formatting Changes
# if: steps.git-check.outputs.changes_detected == 'true'
# uses: EndBug/add-and-commit@v9
# with:
# # File yang di-commit adalah semua perubahan
# message: '🖌️ Style: Apply automatic code formatting via GitHub Actions'
# # Gunakan token GITHUB_TOKEN bawaan untuk push
# github_token: ${{ secrets.GITHUB_TOKEN }}
# # Nama dan email bot
# author_name: GitHub Actions Bot
# author_email: actions-bot@users.noreply.github.com