-
Notifications
You must be signed in to change notification settings - Fork 2
98 lines (86 loc) · 3.29 KB
/
Copy pathsync.yml
File metadata and controls
98 lines (86 loc) · 3.29 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
95
96
97
98
name: Sync English manual from upstream
on:
schedule:
# Every Saturday at 03:03 UTC
- cron: '3 3 * * 6'
workflow_dispatch:
inputs:
reason:
description: Optional reason for manual run
required: false
permissions:
contents: write
issues: write
concurrency:
group: sync-i18n-en
cancel-in-progress: false
env:
UPSTREAM_REPO: omegat-org/omegat
DEFAULT_BRANCH: master
OLD_MAINTAINANCE_BRANCH: releases/6.0
OLD_MAINTAINANCE_TREE_DIR: omegat-releases-6.0
OLD_MAINTAINANCE_BRANCH_TARGET: manuals-6.0
MAINTAINANCE_BRANCH: releases/6.1
MAINTAINANCE_TREE_DIR: omegat-releases-6.1
MAINTAINANCE_BRANCH_TARGET: manual-6.1
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout target repository
uses: actions/checkout@v5
with:
ref: master
fetch-depth: 0
- name: Set up Git user
run: |
git config user.name "github-actions[bot]"
git config user.email "[email protected]"
- name: Fetch from upstream repository
run: |
git clone --depth=1 https://github.com/${{ env.UPSTREAM_REPO }}.git _upstream
curl -L -o _upstream/branch.tar.gz https://github.com/${{ env.UPSTREAM_REPO }}/archive/refs/heads/${{ env.MAINTAINANCE_BRANCH }}.tar.gz
curl -L -o _upstream/oldbranch.tar.gz https://github.com/${{ env.UPSTREAM_REPO }}/archive/refs/heads/${{ env.OLD_MAINTAINANCE_BRANCH }}.tar.gz
cd _upstream
tar xf branch.tar.gz
tar xf oldbranch.tar.gz
- name: Replace local English with upstream version
run: |
set -e
rm -rf en || true
rm -rf greeting || true
rm -rf tips || true
rm -rf ${{ env.BRANCH_TARGET }} || true
mkdir -p manual
mkdir -p greeting
mkdir -p tips
mkdir -p ${{ env.MAINTAINANCE_BRANCH_TARGET }}
mkdir -p ${{ env.OLD_MAINTAINANCE_BRANCH_TARGET }}
# Copy manual, greeting and tips from src/docs/* at master branch
cp -r _upstream/src/docs/manual/en/* ./manual/
cp -r _upstream/src/docs/greeting/en/* ./greeting/
cp -r _upstream/src/docs/tips/en/* ./tips/
# Copy manual from src_docs/ at releases/6.1 branch
cp -r _upstream/${{ env.MAINTAINANCE_TREE_DIR }}/src_docs/manual/en/* ./${{ env.MAINTAINANCE_BRANCH_TARGET }}/
# Copy manual from doc_src/ at releases/6.0 branch
cp -r _upstream/${{ env.OLD_MAINTAINANCE_TREE_DIR }}/doc_src/en/* ./${{ env.OLD_MAINTAINANCE_BRANCH_TARGET }}/
- name: Stage changes
run: |
git add manual greeting tips ${{ env.OLD_MAINTAINANCE_BRANCH_TARGET }} ${{ env.MAINTAINANCE_BRANCH_TARGET }}
- name: Check for differences
id: diff
run: |
if git diff --staged --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Commit changes
if: steps.diff.outputs.changed == 'true'
run: |
ts="$(date -u +'%Y-%m-%d')"
git commit -m "Sync manual(en) from upstream ${UPSTREAM_REPO} on ${ts}"
- name: Push to master
if: steps.diff.outputs.changed == 'true'
run: |
git push origin HEAD:master