Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4592fcd

Browse files
authored
Update workflow and make it reusable (#315)
* Update workflow definition and dependencies version. * Simplify the code structure. * Make workflow reusable across versions.
1 parent df8186d commit 4592fcd

11 files changed

+79
-127
lines changed

.github/scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ error() {
1313
cd cpython/Doc || exit 1
1414
mkdir -p locales/"$LOCALE"/
1515
ln -sfn "$(realpath ../../docs)" locales/"$LOCALE"/LC_MESSAGES
16-
make venv
17-
make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going -j2" 2> >(error)
16+
pip3 install -q -r requirements.txt
17+
make html SPHINXOPTS="-D language=$LOCALE -D gettext_compact=0 -W --keep-going" 2> >(error)

.github/scripts/commit.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ if ! git status -s|grep '\.po'; then
1111
fi
1212
git add .
1313
git commit -m '[po] auto sync'
14-
header="$(echo -n token:"$GITHUB_TOKEN" | base64)"
15-
git -c http.extraheader="AUTHORIZATION: basic $header" push
14+
git push

.github/scripts/prepare.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,4 @@
22

33
set -ex
44

5-
git clone --depth=1 --branch="$VERSION" https://github.com/python/cpython cpython
6-
git clone --branch="$VERSION" https://github.com/"$GITHUB_REPOSITORY" docs
7-
8-
pip3 install --user setuptools
9-
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
10-
sudo apt-get update
11-
sudo apt-get install -y python3-venv
5+
curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash

.github/scripts/update.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/bin/bash
22

3-
tx=$(realpath ./tx)
43
cd docs || exit 1
5-
$tx pull --languages "$LOCALE" -t --use-git-timestamps
4+
$(realpath ../tx) pull --languages "$LOCALE" -t --use-git-timestamps --workers 25 --silent

.github/workflows/python-310.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,12 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "8 * * * *"
8+
- cron: "26 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.10"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.10"
15+
secrets: inherit
16+

.github/workflows/python-311.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,12 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "11 * * * *"
8+
- cron: "38 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.11"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.11"
15+
secrets: inherit
16+

.github/workflows/python-312.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,11 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "42 * * * *"
8+
- cron: "50 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.12"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.12"
15+
secrets: inherit

.github/workflows/python-37.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,11 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "53 * * * *"
8+
- cron: "0 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.7"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.7"
15+
secrets: inherit

.github/workflows/python-38.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,11 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "38 * * * *"
8+
- cron: "2 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.8"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.8"
15+
secrets: inherit

.github/workflows/python-39.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,12 @@ on:
55
branches:
66
- master
77
schedule:
8-
- cron: "23 * * * *"
8+
- cron: "14 * * * *"
99

1010
jobs:
1111
sync:
12-
runs-on: ubuntu-latest
13-
env:
14-
LOCALE: zh_CN
15-
VERSION: "3.9"
16-
steps:
17-
- uses: actions/checkout@v2
18-
- name: prepare
19-
run: .github/scripts/prepare.sh
20-
- name: update
21-
run: .github/scripts/update.sh
22-
env:
23-
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
24-
- name: build
25-
run: .github/scripts/build.sh
26-
- name: commit
27-
run: .github/scripts/commit.sh
28-
env:
29-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12+
uses: ./.github/workflows/sync.yml
13+
with:
14+
version: "3.9"
15+
secrets: inherit
16+

.github/workflows/sync.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Reusable workflow example
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
secrets:
10+
TRANSIFEX_APIKEY:
11+
required: true
12+
13+
jobs:
14+
sync:
15+
runs-on: ubuntu-latest
16+
env:
17+
LOCALE: zh_CN
18+
VERSION: ${{ inputs.version }}
19+
steps:
20+
- uses: actions/checkout@v3
21+
- name: Checkout CPython
22+
uses: actions/checkout@v3
23+
with:
24+
repository: 'python/cpython'
25+
ref: ${{env.VERSION}}
26+
path: cpython
27+
- name: Checkout Current Branch
28+
uses: actions/checkout@v3
29+
with:
30+
ref: ${{env.VERSION}}
31+
path: docs
32+
- name: prepare
33+
run: .github/scripts/prepare.sh
34+
- name: update
35+
run: .github/scripts/update.sh
36+
env:
37+
TX_TOKEN: ${{ secrets.TRANSIFEX_APIKEY }}
38+
- name: build
39+
run: .github/scripts/build.sh
40+
- name: commit
41+
run: .github/scripts/commit.sh

0 commit comments

Comments
 (0)