Skip to content

Update workflow and make it reusable #315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ error() {
cd cpython/Doc || exit 1
mkdir -p locales/"$LOCALE"/
ln -sfn "$(realpath ../../docs)" locales/"$LOCALE"/LC_MESSAGES
make venv
make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going -j2" 2> >(error)
pip3 install -q -r requirements.txt
make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going" 2> >(error)
3 changes: 1 addition & 2 deletions .github/scripts/commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ if ! git status -s|grep '\.po'; then
fi
git add .
git commit -m '[po] auto sync'
header="$(echo -n token:"$GITHUB_TOKEN" | base64)"
git -c http.extraheader="AUTHORIZATION: basic $header" push
git push
8 changes: 1 addition & 7 deletions .github/scripts/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,4 @@

set -ex

git clone --depth=1 --branch="$VERSION" https://github.com/python/cpython cpython
git clone --branch="$VERSION" https://github.com/"$GITHUB_REPOSITORY" docs

pip3 install --user setuptools
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
sudo apt-get update
sudo apt-get install -y python3-venv
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
3 changes: 1 addition & 2 deletions .github/scripts/update.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/bin/bash

tx=$(realpath ./tx)
cd docs || exit 1
$tx pull --languages "$LOCALE" -t --use-git-timestamps
$(realpath ../tx) pull --languages "$LOCALE" -t --use-git-timestamps --workers 25 --silent
25 changes: 6 additions & 19 deletions .github/workflows/python-310.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ on:
branches:
- master
schedule:
- cron: "8 * * * *"
- cron: "26 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.10"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.10"
secrets: inherit

25 changes: 6 additions & 19 deletions .github/workflows/python-311.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ on:
branches:
- master
schedule:
- cron: "11 * * * *"
- cron: "38 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.11"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.11"
secrets: inherit

24 changes: 5 additions & 19 deletions .github/workflows/python-312.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,11 @@ on:
branches:
- master
schedule:
- cron: "42 * * * *"
- cron: "50 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.12"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.12"
secrets: inherit
24 changes: 5 additions & 19 deletions .github/workflows/python-37.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,11 @@ on:
branches:
- master
schedule:
- cron: "53 * * * *"
- cron: "0 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.7"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.7"
secrets: inherit
24 changes: 5 additions & 19 deletions .github/workflows/python-38.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,11 @@ on:
branches:
- master
schedule:
- cron: "38 * * * *"
- cron: "2 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.8"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.8"
secrets: inherit
25 changes: 6 additions & 19 deletions .github/workflows/python-39.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,12 @@ on:
branches:
- master
schedule:
- cron: "23 * * * *"
- cron: "14 * * * *"

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: "3.9"
steps:
- uses: actions/checkout@v2
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: ./.github/workflows/sync.yml
with:
version: "3.9"
secrets: inherit

41 changes: 41 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Reusable workflow example

on:
workflow_call:
inputs:
version:
required: true
type: string
secrets:
TRANSIFEX_APIKEY:
required: true

jobs:
sync:
runs-on: ubuntu-latest
env:
LOCALE: zh_CN
VERSION: ${{ inputs.version }}
steps:
- uses: actions/checkout@v3
- name: Checkout CPython
uses: actions/checkout@v3
with:
repository: 'python/cpython'
ref: ${{env.VERSION}}
path: cpython
- name: Checkout Current Branch
uses: actions/checkout@v3
with:
ref: ${{env.VERSION}}
path: docs
- name: prepare
run: .github/scripts/prepare.sh
- name: update
run: .github/scripts/update.sh
env:
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
- name: build
run: .github/scripts/build.sh
- name: commit
run: .github/scripts/commit.sh