GitHub Actions
With the github action, you can easily translate your code by just pushing your code to the repository, the github action will then translate your new keys, either create a pull request or commit your changes. This saves you a lot of time and effort while maintaining high quality translations.
Installation
To use the Babely GitHub Action in your repository, you'll need to:
- ◇Set up your repository secrets with your Babely credentials
- ◇Create a workflow file in your repository
Setting up Repository Secrets
Add the following secrets in your repository settings (Settings > Secrets and variables > Actions):
- ◇
BABELY_API_KEY: Your Babely API key - ◇
BABELY_PROJECT_ID: Your Babely project ID
You can find these values in your Babely dashboard under Project Settings.
Environment Variables
The GitHub Action uses the following environment variables:
- ◇
BABELY_API_KEY(Required): Your Babely API key for authentication - ◇
BABELY_PROJECT_ID(Required): Your Babely project ID - ◇
GITHUB_TOKEN(Required): Automatically provided by GitHub, used for creating PRs
Example Workflow
Create a new file .github/workflows/babely.yml in your repository with the following content:
name: Deploy Website on: push: branches: - '**' paths: - apps/web/** jobs: translate: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - uses: actions/checkout@v4 - name: Babely Action uses: babely-ai/babely@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: api-key: ${{ secrets.BABELY_API_KEY }} project-id: ${{ secrets.BABELY_PROJECT_ID }}
This workflow will:
- ◇Run on pushes to the main branch
- ◇Run on pull requests to the main branch
- ◇Can be triggered manually from the Actions tab
- ◇Checkout your code and run the Babely translation process
- ◇Create a pull request with any new translations (configurable)
Working Directory Option
The working-directory option allows you to specify where your translation files are located. This is particularly useful in monorepos where your translations may be in a specific package or app directory. For example:
Pull Request Option (coming soon)
The create-pull-request option controls whether the action creates a pull request with the changes or commits them directly to the branch:
with: create-pull-request: true # create a pull request with the changes
When set to true, the action will:
- ◇Create a new branch with the changes
- ◇Create a pull request for review
- ◇Add appropriate labels and description
When set to false (default), the action will:
- ◇Commit the changes directly to the current branch
- ◇Push the changes without creating a pull request
Using with Vercel
If you're using Vercel for deployments, you can combine this GitHub Action with our Vercel build validation to ensure your translations are always synchronized before deployment. This prevents deployments with missing or outdated translations.