Skip to content

Commit 29909dd

Browse files
authored
Merge pull request #1 from ppippi-dev/feat/translate-auto
번역 workflow 자동화
2 parents f96043a + 3055ded commit 29909dd

File tree

5 files changed

+258
-277
lines changed

5 files changed

+258
-277
lines changed

.github/workflows/jekyll-docker.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ name: Build and Deploy to GitHub Pages
33
on:
44
push:
55
branches: [ "main" ]
6-
pull_request:
7-
branches: [ "main" ]
6+
workflow_run:
7+
workflows: ["Translate new posts to English"]
8+
types: [completed]
89

910
# GitHub Pages에 배포하기 위한 권한 설정
1011
permissions:
@@ -15,10 +16,11 @@ permissions:
1516
# 동시 배포 방지
1617
concurrency:
1718
group: "pages"
18-
cancel-in-progress: false
19+
cancel-in-progress: true
1920

2021
jobs:
2122
build:
23+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
2224
runs-on: ubuntu-latest
2325

2426
steps:
@@ -44,7 +46,7 @@ jobs:
4446
url: ${{ steps.deployment.outputs.page_url }}
4547
runs-on: ubuntu-latest
4648
needs: build
47-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
49+
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') }}
4850

4951
steps:
5052
- name: Deploy to GitHub Pages
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Translate new posts to English
2+
3+
on:
4+
pull_request_target:
5+
types: [closed]
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
translate:
12+
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout main
16+
uses: actions/checkout@v4
17+
with:
18+
ref: main
19+
20+
- name: Get changed files from PR
21+
id: changes
22+
uses: actions/github-script@v7
23+
with:
24+
script: |
25+
const pr = context.payload.pull_request;
26+
const { owner, repo } = context.repo;
27+
const pull_number = pr.number;
28+
const per_page = 100;
29+
let page = 1;
30+
const files = [];
31+
while (true) {
32+
const res = await github.rest.pulls.listFiles({ owner, repo, pull_number, per_page, page });
33+
if (res.data.length === 0) break;
34+
for (const f of res.data) files.push(f.filename);
35+
if (res.data.length < per_page) break;
36+
page += 1;
37+
}
38+
const posts = files.filter(f => f.startsWith('_posts/') && f.endsWith('.md'));
39+
core.setOutput('posts', posts.join('\n'));
40+
41+
- name: Set ONLY_FILES env
42+
if: steps.changes.outputs.posts != ''
43+
run: |
44+
echo 'ONLY_FILES<<EOF' >> $GITHUB_ENV
45+
echo '${{ steps.changes.outputs.posts }}' >> $GITHUB_ENV
46+
echo 'EOF' >> $GITHUB_ENV
47+
48+
- name: Set up Python
49+
if: steps.changes.outputs.posts != ''
50+
uses: actions/setup-python@v5
51+
with:
52+
python-version: '3.11'
53+
54+
- name: Install dependencies
55+
if: steps.changes.outputs.posts != ''
56+
run: |
57+
python -m pip install --upgrade pip
58+
pip install openai PyYAML python-frontmatter python-slugify
59+
60+
- name: Generate English translations
61+
if: steps.changes.outputs.posts != ''
62+
env:
63+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
64+
TRANSLATION_MODEL: ${{ vars.TRANSLATION_MODEL }}
65+
run: |
66+
python scripts/translate_to_en.py
67+
68+
- name: Commit and push translations
69+
if: steps.changes.outputs.posts != ''
70+
uses: stefanzweifel/git-auto-commit-action@v5
71+
with:
72+
commit_message: "chore: add English translations for PR #${{ github.event.pull_request.number }}"
73+
file_pattern: "_posts_en/**/*.md"
74+
75+

_posts/2025-07-03-actions-runner-controller.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,4 +285,3 @@ docker run -it \
285285
ARC를 사용하면 GitHub에서 제공하는 Runner를 사용할 때의 비싼 비용 문제와, 직접 VM을 관리하며 Runner를 운영할 때의 비효율성을 모두 해결할 수 있습니다. 특히 GPU가 필요하거나, 복잡한 의존성을 가진 MLOps CI/CD 환경을 구축할 때 ARC는 매우 강력한 도구가 됩니다.
286286

287287
초기 설정 과정이 다소 복잡하게 느껴질 수 있지만, 한번 구축해두면 CI/CD 비용을 크게 절감하고 운영 부담을 덜어주므로 MLOps를 고민하고 있다면 꼭 한번 도입을 검토해보시길 바랍니다.
288-

_posts_en/2025-07-03-actions-runner-controller.md

Lines changed: 0 additions & 272 deletions
This file was deleted.

0 commit comments

Comments
 (0)