Skip to content

Commit bf9c048

Browse files
committed
Add pomerge workflow and script
1 parent 4fc71f0 commit bf9c048

2 files changed

Lines changed: 525 additions & 0 deletions

File tree

‎.github/workflows/merge-back.yml‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Merge translations back to older branch
2+
3+
on:
4+
schedule:
5+
# After the 04:00 CPython sync and 05:00 maintenance runs, so the newest
6+
# 3.15 translations are what get copied.
7+
- cron: '30 5 * * *'
8+
workflow_dispatch:
9+
inputs:
10+
dst_branch:
11+
description: 'Branch that receives the translations'
12+
required: false
13+
default: '3.14'
14+
dry_run:
15+
description: 'Report only, do not commit or push'
16+
type: boolean
17+
default: false
18+
overwrite:
19+
description: 'On conflicts take the 3.15 translation instead of keeping the existing one'
20+
type: boolean
21+
default: false
22+
23+
permissions:
24+
contents: write
25+
26+
# Shared with sync-with-cpython.yml and maintenance.yml: they push to 3.15,
27+
# this one reads 3.15, so they must not overlap.
28+
concurrency:
29+
group: repo-writes
30+
cancel-in-progress: false
31+
32+
env:
33+
SRC_BRANCH: '3.15'
34+
DST_BRANCH: ${{ github.event.inputs.dst_branch || '3.14' }}
35+
36+
jobs:
37+
merge-back:
38+
runs-on: ubuntu-latest
39+
timeout-minutes: 15
40+
steps:
41+
# fetch-depth 0 brings every branch down as origin/*, which is how the
42+
# script finds 3.14 (it creates the local branch itself).
43+
- name: Checkout translation repo
44+
uses: actions/checkout@v4
45+
with:
46+
ref: ${{ env.SRC_BRANCH }}
47+
fetch-depth: 0
48+
49+
- name: Configure git identity
50+
run: |
51+
git config user.name "github-actions[bot]"
52+
git config user.email "github-actions[bot]@users.noreply.github.com"
53+
54+
- name: Merge ${{ env.SRC_BRANCH }} translations into ${{ env.DST_BRANCH }}
55+
env:
56+
DRY_RUN: ${{ github.event.inputs.dry_run }}
57+
OVERWRITE: ${{ github.event.inputs.overwrite }}
58+
run: |
59+
args=(--src "$SRC_BRANCH" --dst "$DST_BRANCH" --fetch
60+
--conflicts-file "$RUNNER_TEMP/conflicts.txt")
61+
if [ "$DRY_RUN" = "true" ]; then
62+
args+=(--dry-run)
63+
else
64+
args+=(--push)
65+
fi
66+
if [ "$OVERWRITE" = "true" ]; then
67+
args+=(--overwrite)
68+
fi
69+
python3 scripts/po_merge_back.py "${args[@]}" | tee "$RUNNER_TEMP/report.txt"
70+
71+
# Conflicts (both branches translated, different text) are kept as-is on
72+
# the destination; surface them so a human can decide.
73+
- name: Publish report
74+
if: always()
75+
run: |
76+
{
77+
echo "### Merge ${SRC_BRANCH} → ${DST_BRANCH}"
78+
if [ -f "$RUNNER_TEMP/report.txt" ]; then
79+
echo '```'
80+
tail -n 12 "$RUNNER_TEMP/report.txt"
81+
echo '```'
82+
fi
83+
if [ -s "$RUNNER_TEMP/conflicts.txt" ]; then
84+
echo "<details><summary>Conflicts (kept as ${DST_BRANCH})</summary>"
85+
echo
86+
echo '```'
87+
head -c 200000 "$RUNNER_TEMP/conflicts.txt"
88+
echo '```'
89+
echo "</details>"
90+
fi
91+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)