[#255] fastlane 배포 시 빌드 자동화를 우선 시행하도록 한다 #236
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS CI | |
| on: | |
| pull_request: | |
| env: | |
| SCHEME: DevLog | |
| XCODE_VERSION: latest | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| checks: write | |
| jobs: | |
| detect_qa_tag: | |
| runs-on: macos-latest | |
| outputs: | |
| has_qa_tag: ${{ steps.detect.outputs.has_qa_tag }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Detect QA Tag on PR Head | |
| id: detect | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| PR_HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
| MATCHED_TAG="$(git tag --points-at "$PR_HEAD_SHA" | grep -E '^qa(-local)?-' | head -n 1 || true)" | |
| if [ -n "$MATCHED_TAG" ]; then | |
| echo "Found QA tag on PR head: $MATCHED_TAG" | |
| echo "has_qa_tag=true" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| echo "No QA tag found on PR head" | |
| echo "has_qa_tag=false" >> "$GITHUB_OUTPUT" | |
| build: | |
| needs: detect_qa_tag | |
| if: needs.detect_qa_tag.outputs.has_qa_tag != 'true' | |
| runs-on: macos-latest | |
| timeout-minutes: 30 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Xcode | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: ${{ env.XCODE_VERSION }} | |
| - name: Cache SwiftPM | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.swiftpm | |
| ~/Library/Caches/org.swift.swiftpm | |
| ~/Library/Developer/Xcode/SourcePackages | |
| .spm | |
| key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }} | |
| restore-keys: | | |
| ${{ runner.os }}-spm- | |
| - name: Build | |
| uses: ./.github/actions/ios-simulator-build | |
| with: | |
| scheme: ${{ env.SCHEME }} | |
| - name: Comment build failure on PR | |
| if: failure() && github.event.pull_request.head.repo.fork == false | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = 'build.log'; | |
| let body = '❌ iOS CI build failed.\n\n'; | |
| if (fs.existsSync(path)) { | |
| const log = fs.readFileSync(path, 'utf8'); | |
| const lines = log.split(/\r?\n/); | |
| const errorLines = lines.filter((line) => /error:/i.test(line)); | |
| if (errorLines.length > 0) { | |
| body += "Lines containing 'error:':\n\n```\n" + errorLines.join('\n') + '\n```\n'; | |
| const repoRoot = process.env.GITHUB_WORKSPACE || process.cwd(); | |
| const pathMod = require('path'); | |
| const snippets = []; | |
| for (const line of errorLines) { | |
| const match = line.match(/^(.*?):(\d+):(\d+):\s+error:/); | |
| if (!match) continue; | |
| const filePath = match[1]; | |
| const lineNum = parseInt(match[2], 10); | |
| const absPath = filePath.startsWith('/') ? filePath : pathMod.join(repoRoot, filePath); | |
| if (!fs.existsSync(absPath)) continue; | |
| const fileLines = fs.readFileSync(absPath, 'utf8').split(/\r?\n/); | |
| const start = Math.max(0, lineNum - 3); | |
| const end = Math.min(fileLines.length, lineNum + 2); | |
| const snippet = fileLines | |
| .slice(start, end) | |
| .map((l, idx) => { | |
| const ln = start + idx + 1; | |
| return `${ln.toString().padStart(4, ' ')}| ${l}`; | |
| }) | |
| .join('\n'); | |
| snippets.push(`File: ${filePath}:${lineNum}\n${snippet}`); | |
| } | |
| if (snippets.length > 0) { | |
| body += "\nCode excerpts:\n\n```\n" + snippets.join('\n\n') + "\n```\n"; | |
| } | |
| } else { | |
| body += "No lines containing 'error:' were found in build.log."; | |
| } | |
| } else { | |
| body += 'build.log not found.'; | |
| } | |
| if (!context.payload.pull_request) { | |
| core.info('No PR context; skipping comment.'); | |
| return; | |
| } | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.payload.pull_request.number, | |
| body | |
| }); |