-
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add github workflows to update translation
- Loading branch information
Showing
8 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM debian:stable-slim | ||
|
||
RUN set -ex \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends git ca-certificates \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
name: Commit Translation | ||
description: Commit translation in git repo and push to remote | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
cd docs || exit 1 | ||
git config user.email "[email protected]" | ||
git config user.name "Github Actions" | ||
if git status -s|grep '\.po'; then | ||
git add . | ||
git commit -m '[po] auto sync' | ||
header="$(echo -n token:"$GITHUB_TOKEN" | base64)" | ||
git -c http.extraheader="AUTHORIZATION: basic $header" push | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3-slim | ||
|
||
RUN set -ex \ | ||
&& pip install transifex-client \ | ||
&& rm -rf ~/.cache \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends git make \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Update Translation | ||
description: Update Python Doc Translation from Transifex | ||
inputs: | ||
pythonVersion: | ||
description: Python Version | ||
required: true | ||
locale: | ||
description: Locale Name | ||
required: true | ||
default: zh_CN | ||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
args: | ||
- ${{ inputs.pythonVersion }} | ||
- ${{ inputs.locale }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
pythonVersion="$1" | ||
locale="$2" | ||
|
||
echo "Python Version: $pythonVersion" | ||
echo "Locale: $locale" | ||
|
||
cur=$(pwd) | ||
git clone --depth=1 --branch="$pythonVersion" https://github.com/python/cpython cpython | ||
git clone --branch="$pythonVersion" https://github.com/"$GITHUB_REPOSITORY" docs | ||
|
||
if [[ -n "$TRANSIFEX_APIKEY" ]]; then | ||
cat > ~/.transifexrc << EOF | ||
[https://www.transifex.com] | ||
api_hostname = https://api.transifex.com | ||
hostname = https://www.transifex.com | ||
password = $TRANSIFEX_APIKEY | ||
username = api | ||
EOF | ||
fi | ||
|
||
# Pull Transifex translation | ||
pushd docs || exit 1 | ||
tx pull --force --parallel --language "$locale" | ||
popd || exit 1 | ||
|
||
# Test building docs | ||
pushd cpython/Doc || exit 1 | ||
mkdir -p locales/"$locale"/ | ||
ln -sfn "$cur"/docs locales/"$locale"/LC_MESSAGES | ||
make venv | ||
make html SPHINXOPTS="-D language=$locale -D gettext_compact=0 -j4 -W --keep-going" | ||
popd || exit 1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: python-37 | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "38 * * * *" | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: ./.github/actions/update | ||
with: | ||
pythonVersion: "3.7" | ||
locale: zh_CN | ||
env: | ||
TRANSIFEX_APIKEY: ${{ secrets.TRANSIFEX_APIKEY }} | ||
- uses: ./.github/actions/commit | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: python-38 | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
schedule: | ||
- cron: "18 * * * *" | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
with: | ||
fetch-depth: 1 | ||
- uses: ./.github/actions/update | ||
with: | ||
pythonVersion: "3.8" | ||
locale: zh_CN | ||
env: | ||
TRANSIFEX_APIKEY: ${{ secrets.TRANSIFEX_APIKEY }} | ||
- uses: ./.github/actions/commit | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |