|
5 | 5 | - [No-crowdin.yml configuration](#no-crowdinyml-configuration) |
6 | 6 | - [Upload sources only](#upload-sources-only) |
7 | 7 | - [Upload sources to the branch in Crowdin](#upload-sources-to-the-branch-in-crowdin) |
| 8 | +- [Caching source files for faster uploads](#caching-source-files-for-faster-uploads) |
8 | 9 | - [Download only translations without pushing to a branch](#download-only-translations-without-pushing-to-a-branch) |
9 | 10 | - [Download Bundle](#download-bundle) |
10 | 11 | - [Advanced Pull Request configuration](#advanced-pull-request-configuration) |
@@ -189,6 +190,53 @@ jobs: |
189 | 190 |
|
190 | 191 | Note that the value of the `crowdin_branch_name` is `env.BRANCH_NAME` - this is the name of the current branch on which the action is running. |
191 | 192 |
|
| 193 | +### Caching source files for faster uploads |
| 194 | + |
| 195 | +The Crowdin CLI supports a `--cache` parameter for the `upload sources` command that stores source file checksums locally. This allows the CLI to only upload files that have changed, significantly reducing upload time for large projects. |
| 196 | + |
| 197 | +> **Note** |
| 198 | +> The cache feature is experimental. For any feedback, visit [Crowdin CLI Discussions](https://github.com/crowdin/crowdin-cli/discussions). |
| 199 | + |
| 200 | +To persist the cache between workflow runs, use the `actions/cache` action to save and restore the cache file located at `~/.crowdin/cache.json`: |
| 201 | + |
| 202 | +```yaml |
| 203 | +name: Crowdin Action |
| 204 | +
|
| 205 | +on: |
| 206 | + push: |
| 207 | + branches: [ main ] |
| 208 | +
|
| 209 | +jobs: |
| 210 | + crowdin: |
| 211 | + runs-on: ubuntu-latest |
| 212 | + steps: |
| 213 | + - name: Checkout |
| 214 | + uses: actions/checkout@v4 |
| 215 | +
|
| 216 | + - name: Cache Crowdin source files |
| 217 | + uses: actions/cache@v4 |
| 218 | + with: |
| 219 | + path: ~/.crowdin/cache.json |
| 220 | + key: ${{ runner.os }}-crowdin-cache-${{ github.ref_name }}-${{ hashFiles('**/crowdin.yml') }} |
| 221 | + restore-keys: | |
| 222 | + ${{ runner.os }}-crowdin-cache-${{ github.ref_name }}- |
| 223 | +
|
| 224 | + - name: Crowdin push |
| 225 | + uses: crowdin/github-action@v2 |
| 226 | + with: |
| 227 | + upload_sources: true |
| 228 | + upload_translations: false |
| 229 | + download_translations: false |
| 230 | + upload_sources_args: '--cache' |
| 231 | + env: |
| 232 | + CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} |
| 233 | + CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |
| 234 | +``` |
| 235 | + |
| 236 | +The cache key includes the current branch name and the `crowdin.yml` file hash, so each branch maintains its own cache and the cache will be invalidated when your Crowdin configuration changes. The `restore-keys` ensures that even if the exact key doesn't match (e.g., when `crowdin.yml` changes), a previous cache for the same branch will be restored, which is useful for incremental updates. |
| 237 | + |
| 238 | +Make sure to pass the `--cache` argument to the `upload_sources_args` option to use the cache. |
| 239 | + |
192 | 240 | ### Download only translations without pushing to a branch |
193 | 241 |
|
194 | 242 | It's possible to just download the translations without creating a PR immediately. It allows you to post-process the downloaded translations and create a PR later. |
|
0 commit comments