-
Notifications
You must be signed in to change notification settings - Fork 9.4k
107 lines (95 loc) · 3.81 KB
/
Copy pathgp-download.yml
File metadata and controls
107 lines (95 loc) · 3.81 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
99
100
101
102
103
104
105
106
107
name: GP Download Translations
on:
schedule:
- cron: "0 23 * * *" # 11 PM UTC — 1h before nightly build at midnight
workflow_dispatch:
jobs:
download:
runs-on: ubuntu-latest
name: Download translations from Globalization Pipeline
environment: GP-test
permissions:
contents: write
pull-requests: write
steps:
- name: Resolve latest release branch
id: resolve-branch
run: |
BRANCH=$(git ls-remote --heads https://github.com/${{ github.repository }} 'refs/heads/release-*' \
| awk '{print $2}' \
| sed 's|refs/heads/||' \
| grep -E '^release-[0-9]+\.[0-9]+\.[0-9]+$' \
| sort -V \
| tail -n 1)
if [ -z "$BRANCH" ]; then
echo "No release-* branch found in ${{ github.repository }}"
exit 1
fi
echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT"
echo "Using release branch: $BRANCH"
- name: Checkout release branch
uses: actions/checkout@v4
with:
ref: ${{ steps.resolve-branch.outputs.branch }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: pip install -r scripts/gp/requirements.txt
- name: Download translations from GP
working-directory: scripts/gp
env:
GP_ADMIN_USER_ID: ${{ secrets.GP_ADMIN_USER_ID }}
GP_ADMIN_PASSWORD: ${{ secrets.GP_ADMIN_PASSWORD }}
GP_INSTANCE: ${{ vars.GP_INSTANCE }}
GP_BUNDLE: ${{ vars.GP_BUNDLE }}
run: python download_translations.py --output ../../src/frontend/src/locales/
- name: Close stale translation PRs
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open'
});
for (const pull of pulls) {
if (pull.title === "chore: update translations from Globalization Pipeline") {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull.number,
state: 'closed'
});
}
}
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v8
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch-token: ${{ secrets.GITHUB_TOKEN }}
base: ${{ steps.resolve-branch.outputs.branch }}
commit-message: "chore: update translations from Globalization Pipeline [skip ci]"
title: "chore: update translations from Globalization Pipeline"
body: |
Automated PR to update locale files from IBM Globalization Pipeline.
This PR was automatically created by the `gp-download` workflow.
If no files changed, this PR will be empty and can be closed.
branch: translations/update-gp
branch-suffix: timestamp
delete-branch: true
maintainer-can-modify: true
add-paths: src/frontend/src/locales/*.json
- name: Enable auto-merge
if: steps.create-pr.outputs.pull-request-number != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash \
--repo ${{ github.repository }}
- name: Report GP download failure
if: failure()
run: echo "::warning::GP translation download failed — translations may be out of date. Check the 'Download translations from GP' step above for details."