|
51 | 51 | GP_ADMIN_PASSWORD: ${{ secrets.GP_ADMIN_PASSWORD }} |
52 | 52 | GP_INSTANCE: ${{ vars.GP_INSTANCE }} |
53 | 53 | GP_BUNDLE: ${{ vars.GP_BUNDLE }} |
54 | | - run: python download_translations.py --output ../../src/frontend/src/locales/ |
| 54 | + run: python download.py --target frontend --output ../../src/frontend/src/locales/ |
55 | 55 |
|
56 | 56 | - name: Close stale translation PRs |
57 | 57 | uses: actions/github-script@v8 |
@@ -105,3 +105,104 @@ jobs: |
105 | 105 | - name: Report GP download failure |
106 | 106 | if: failure() |
107 | 107 | run: echo "::warning::GP translation download failed — translations may be out of date. Check the 'Download translations from GP' step above for details." |
| 108 | + |
| 109 | + download-backend: |
| 110 | + if: github.event_name == 'workflow_dispatch' |
| 111 | + runs-on: ubuntu-latest |
| 112 | + name: Download backend translations from Globalization Pipeline |
| 113 | + environment: GP-test |
| 114 | + permissions: |
| 115 | + contents: write |
| 116 | + pull-requests: write |
| 117 | + |
| 118 | + steps: |
| 119 | + - name: Resolve latest release branch |
| 120 | + id: resolve-branch |
| 121 | + run: | |
| 122 | + BRANCH=$(git ls-remote --heads https://github.com/${{ github.repository }} 'refs/heads/release-*' \ |
| 123 | + | awk '{print $2}' \ |
| 124 | + | sed 's|refs/heads/||' \ |
| 125 | + | grep -E '^release-[0-9]+\.[0-9]+\.[0-9]+$' \ |
| 126 | + | sort -V \ |
| 127 | + | tail -n 1) |
| 128 | + if [ -z "$BRANCH" ]; then |
| 129 | + echo "No release-* branch found in ${{ github.repository }}" |
| 130 | + exit 1 |
| 131 | + fi |
| 132 | + echo "branch=${BRANCH}" >> "$GITHUB_OUTPUT" |
| 133 | + echo "Using release branch: $BRANCH" |
| 134 | +
|
| 135 | + - name: Checkout release branch |
| 136 | + uses: actions/checkout@v4 |
| 137 | + with: |
| 138 | + ref: ${{ steps.resolve-branch.outputs.branch }} |
| 139 | + |
| 140 | + - name: Set up Python |
| 141 | + uses: actions/setup-python@v5 |
| 142 | + with: |
| 143 | + python-version: "3.12" |
| 144 | + |
| 145 | + - name: Install dependencies |
| 146 | + run: pip install -r scripts/gp/requirements.txt |
| 147 | + |
| 148 | + - name: Download backend translations from GP |
| 149 | + working-directory: scripts/gp |
| 150 | + env: |
| 151 | + GP_ADMIN_USER_ID: ${{ secrets.GP_ADMIN_USER_ID }} |
| 152 | + GP_ADMIN_PASSWORD: ${{ secrets.GP_ADMIN_PASSWORD }} |
| 153 | + GP_INSTANCE: ${{ vars.GP_INSTANCE }} |
| 154 | + GP_BACKEND_BUNDLE: ${{ vars.GP_BACKEND_BUNDLE }} |
| 155 | + run: python download.py --target backend |
| 156 | + |
| 157 | + - name: Close stale backend translation PRs |
| 158 | + uses: actions/github-script@v8 |
| 159 | + with: |
| 160 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + script: | |
| 162 | + const { data: pulls } = await github.rest.pulls.list({ |
| 163 | + owner: context.repo.owner, |
| 164 | + repo: context.repo.repo, |
| 165 | + state: 'open' |
| 166 | + }); |
| 167 | + for (const pull of pulls) { |
| 168 | + if (pull.title === "chore: update backend translations from Globalization Pipeline") { |
| 169 | + await github.rest.pulls.update({ |
| 170 | + owner: context.repo.owner, |
| 171 | + repo: context.repo.repo, |
| 172 | + pull_number: pull.number, |
| 173 | + state: 'closed' |
| 174 | + }); |
| 175 | + } |
| 176 | + } |
| 177 | +
|
| 178 | + - name: Create Pull Request |
| 179 | + id: create-pr |
| 180 | + uses: peter-evans/create-pull-request@v8 |
| 181 | + with: |
| 182 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 183 | + branch-token: ${{ secrets.GITHUB_TOKEN }} |
| 184 | + base: ${{ steps.resolve-branch.outputs.branch }} |
| 185 | + commit-message: "chore: update backend translations from Globalization Pipeline [skip ci]" |
| 186 | + title: "chore: update backend translations from Globalization Pipeline" |
| 187 | + body: | |
| 188 | + Automated PR to update backend locale files from IBM Globalization Pipeline. |
| 189 | +
|
| 190 | + This PR was automatically created by the `gp-download` workflow. |
| 191 | + If no files changed, this PR will be empty and can be closed. |
| 192 | + branch: translations/update-backend-gp |
| 193 | + branch-suffix: timestamp |
| 194 | + delete-branch: true |
| 195 | + maintainer-can-modify: true |
| 196 | + add-paths: src/backend/base/langflow/locales/*.json |
| 197 | + |
| 198 | + - name: Enable auto-merge |
| 199 | + if: steps.create-pr.outputs.pull-request-number != '' |
| 200 | + env: |
| 201 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 202 | + run: | |
| 203 | + gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} --auto --squash \ |
| 204 | + --repo ${{ github.repository }} |
| 205 | +
|
| 206 | + - name: Report GP backend download failure |
| 207 | + if: failure() |
| 208 | + run: echo "::warning::GP backend translation download failed — backend translations may be out of date. Check the 'Download backend translations from GP' step above for details." |
0 commit comments