-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci.yml
More file actions
71 lines (61 loc) · 2.89 KB
/
Copy pathci.yml
File metadata and controls
71 lines (61 loc) · 2.89 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
name: CI
# กำหนด Concurrency: หากมีการ push ซ้ำ ให้หยุด job เก่าและรันใหม่ทันที
# เพื่อประหยัดเวลาและทรัพยากร
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches: [ main, develop ] # ระบุ branch ที่ต้องการรัน
pull_request:
branches: [ main, develop ]
jobs:
test:
runs-on: ubuntu-latest
# 1. Security: กำหนดสิทธิ์ของ GITHUB_TOKEN ให้แคบที่สุดเท่าที่จำเป็น
permissions:
contents: read
# packages: write # ปลดคอมเมนต์หากต้องการ push ไปยัง GitHub Packages
# id-token: write # ปลดคอมเมนต์หากต้องการใช้ OIDC สำหรับ cloud authentication
steps:
# 2. Security: Checkout code โดย Pin เป็น SHA แทน Tag
- name: Checkout code
uses: actions/checkout@v4
# แนะนำ: แลกเปลี่ยน SHA ด้านล่างด้วย SHA ล่าสุดของ actions/checkout@v4
# ค้นหา SHA ล่าสุดได้ที่: https://github.com/actions/checkout/releases
# ตัวอย่าง SHA: a824008085750b8e136effc585c3cd6082bd575f
# ระบุ SHA โดยตรง: uses: actions/checkout@a824008085750b8e136effc585c3cd6082bd575f
# 3. Efficiency: Cache dependencies เพื่อลดเวลาโหลด
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.npm
~/.cache/pip
~/.m2
node_modules
key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json', '**/pom.xml', '**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-build-
${{ runner.os }}-
- name: Setup environment (Customize this based on your project)
# ตัวอย่าง: Setup Node.js หรือ Python
# uses: actions/setup-node@v4
# with:
# node-version: '20'
- name: Install dependencies
run: |
echo "Installing dependencies..."
# คำสั่งติดตั้งจริงของโปรเจคคุณ (เช่น npm ci, pip install -r requirements.txt)
# npm ci
# pip install -r requirements.txt
- name: Run tests
run: |
echo "Running tests..."
# คำสั่งรัน test จริง (เช่น npm test, pytest)
# npm test
# pytest
- name: Build (Optional)
run: |
echo "Building project..."
# คำสั่ง build จริง