Skip to content

Replexica Bitbucket Pipe

Overview

Setup

To use the Replexica's Bitbucket Pipe, add this to your pipeline file (eg. bitbucket-pipelines.yml):

yaml
script:
  - pipe: replexica/replexica:main

You should also create a REPLEXICA_API_KEY environment variable with your Replexica API key (Repository settings -> Repository variables).

Pull Request Mode

If you want to use the pull request feature, the pipeline needs access to your repository in order to open and close pull requests:

  1. create a new access token for your repository (Repository settings -> Access tokens -> Create Repository Access Token)
    • access token name (eg. Replexica) will be used in pull requests
    • required scopes: read & write repositories, read & write pull requests
  2. add the token as BB_TOKEN variable (Repository settings -> Repository variables)
  3. set pipe variable REPLEXICA_PULL_REQUEST: 'true' like this:
yaml
script:
  - pipe: replexica/replexica:main
    variables:
      REPLEXICA_PULL_REQUEST: "true"

Example

To run the action on every push to a branch that starts with feat/, you can use the following workflow. It will commit and pushupdated locale files to the branch as you push commits with new features. Add this config to your bitbucket-pipelines.yml file:

yaml
image:
  name: atlassian/default-image:2

pipelines:
  branches:
    feat/*:
      - step:
          name: Run i18n
          script:
            - pipe: replexica/replexica:main

How It Operates

Here's a breakdown of the action's process:

  1. It runs npx replexica@latest i18n to process translations.
  2. It stages all changes (git add .).
  3. If there are staged changes, it either:
    • Commits them, pulls and rebases to avoid conflicts, and pushes the changes; or
    • Creates or updates a pull request with the changes.

This process ensures that translation updates are seamlessly integrated into your codebase. The action uses this approach because it allows for automatic conflict resolution (via rebase) and provides a clear audit trail of translation updates.

Customization

You can customize the behavior using the following input parameters:

  • REPLEXICA_API_KEY: Override the API key
  • REPLEXICA_PULL_REQUEST: Set to 'true' to create a pull request instead of pushing directly (default: 'false')
  • REPLEXICA_PULL_REQUEST: Customize the title of the pull request (default: 'feat: update translations via @replexica')
  • REPLEXICA_COMMIT_MESSAGE: Customize the commit message (default: 'feat: update translations via @replexica')
  • BB_TOKEN: Override the Bitbucket access token

Example:

yaml
image:
  name: atlassian/default-image:2

pipelines:
  branches:
    feat/*:
      - step:
          name: Run i18n
          script:
            - pipe: replexica/replexica:main
              variables:
                BB_TOKEN: "${MY_ACCESS_TOKEN}"
                REPLEXICA_API_KEY: "${MY_REPLEXICA_API_KEY}"
                REPLEXICA_PULL_REQUEST: "true"
                REPLEXICA_PULL_REQUEST_TITLE: "Replexica updated your translations"
                REPLEXICA_COMMIT_MESSAGE: "feat: new translations"

Note: The BB_TOKEN environment variable is required when REPLEXICA_PULL_REQUEST is set to 'true'.

These customization options exist because different teams have different workflows and preferences. For instance, some teams might prefer pull requests for better review processes, while others might want direct commits for faster updates.