-
Notifications
You must be signed in to change notification settings - Fork 0
94 lines (76 loc) · 3.31 KB
/
swift.yml
File metadata and controls
94 lines (76 loc) · 3.31 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
name: MLS CI
permissions:
contents: write # ✨ 추가: Push를 위한 권한
on:
pull_request:
branches: [main, dev]
jobs:
autocorrect:
name: 🤖 Autocorrect Workflow
runs-on: macos-15
if: github.actor != 'github-actions[bot]' && github.base_ref == 'dev'
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: 🛠️ Set up Xcode
run: sudo xcode-select -s /Applications/Xcode_16.2.app
- name: ⬇️ Install SwiftLint
run: brew install swiftlint
- name: 🎨 Run SwiftLint Autocorrect
run: swiftlint --fix
- name: 🚀 Commit and Push Changes
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git fetch origin "${GITHUB_HEAD_REF}:${GITHUB_HEAD_REF}"
git checkout "${GITHUB_HEAD_REF}"
BRANCH_NAME="${GITHUB_HEAD_REF}"
if [[ "$BRANCH_NAME" =~ \#([0-9]+) ]]; then
ISSUE_NUMBER="${BASH_REMATCH[1]}"
else
ISSUE_NUMBER=""
fi
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "style/#${ISSUE_NUMBER}: Apply SwiftLint autocorrect"
git push --set-upstream origin "${GITHUB_HEAD_REF}"
else
echo "No changes to commit"
fi
build:
name: 🏗️ Build Workflow
runs-on: macos-15 # 최신 macOS 15 환경에서 실행
if: github.actor != 'github-actions[bot]' # Actions 봇 커밋은 무시
steps:
- name: Checkout Repository # 저장소 코드 체크아웃
uses: actions/checkout@v4
- name: 🛠️ Select Xcode 16.2 # Xcode 16.2 버전 사용 설정
run: sudo xcode-select -s /Applications/Xcode_16.2.app
- name: ⬇️ Install SwiftLint # SwiftLint 설치
run: brew install swiftlint
- name: 🎨 Run SwiftLint # SwiftLint 코드 스타일 검사 실행
run: swiftlint
- name: 🔍 Detect Default Scheme # 기본 scheme 자동 검지
id: detect_scheme
run: |
SCHEME=$(xcodebuild -list -json | jq -r '.project.schemes[0]')
echo "Detected scheme: $SCHEME"
echo "scheme=$SCHEME" >> "$GITHUB_OUTPUT"
- name: 🔍 Detect Latest iPhone Simulator # 최신 사용 가능한 iPhone 시뮬레이터 검지
id: detect_latest_simulator
run: |
DEVICE=$(xcrun simctl list devices available | grep -Eo 'iPhone .* \([0-9A-F\-]+\)' | head -n 1)
UDID=$(echo "$DEVICE" | grep -Eo '[0-9A-F\-]{36}')
NAME=$(echo "$DEVICE" | cut -d '(' -f1 | xargs)
echo "Detected simulator: $NAME ($UDID)"
echo "sim_name=$NAME" >> "$GITHUB_OUTPUT"
echo "sim_udid=$UDID" >> "$GITHUB_OUTPUT"
- name: 🏗️ Build the project # 자동 검지된 Scheme과 Simulator로 빌드 수행
run: |
WORKSPACE=$(find . -name "*.xcworkspace" | head -n 1)
xcodebuild -scheme "${{ steps.detect_scheme.outputs.scheme }}" \
-workspace "$WORKSPACE" \
-destination "platform=iOS Simulator,id=${{ steps.detect_latest_simulator.outputs.sim_udid }}" \
clean build | xcpretty