Monday, April 24, 2023

Github action and .phrase.yml integration

 GitHub Actions is a feature of GitHub that allows you to automate tasks based on events in your repository, such as a new commit or a pull request. .phrase.yml is a configuration file used by the localization platform, Phrase, to manage and automate translations of your project.

Integrating GitHub Actions with .phrase.yml can help automate your localization workflow. Here are the steps to set up the integration:

  1. Create a .phrase.yml file in the root directory of your repository.
  2. Define your Phrase configuration in the .phrase.yml file. This includes specifying the project ID, access token, and other relevant settings.
  3. Create a GitHub Actions workflow file (e.g., localization.yml) in the .github/workflows directory of your repository. This file will contain the steps that GitHub Actions will take when triggered by an event in your repository.
  4. In the workflow file, add the Phrase action, which will trigger the localization process defined in the .phrase.yml file. You can use the official Phrase GitHub Actions by adding the following step to your workflow:
yaml
- name: Phrase Localization uses: phrase/phrase-github-actions@v1 with: project_id: ${{ secrets.PHRASE_PROJECT_ID }} access_token: ${{ secrets.PHRASE_ACCESS_TOKEN }} file_format: "yaml" directory: "locales" command: "pull"

This will run the phrase pull command to download the latest translations from Phrase into your project's locales directory.

  1. Define the event that should trigger the workflow, such as a push to a specific branch, a pull request, or a new release.

Once you have set up the integration, GitHub Actions will automatically trigger the localization process when the defined event occurs, making it easier to manage and automate your translations.