GitHub Actions Free
ByAndrii BodnarVerified Author

Trigger a GitHub Actions Workflow when new translations ready

Try Crowdin

Notify your GitHub Actions Workflow when there are new translations and that the build is required. This guide describes setting up a Crowdin webhook to invoke the build.

GitHub Actions' documentation says we should send the following request to trigger the build:

curl \
  -X POST \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>"\
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/OWNER/REPO/actions/workflows/WORKFLOW_ID/dispatches \
  -d '{"ref":"topic-branch","inputs":{"name":"Mona the Octocat","home":"San Francisco, CA"}}'

Also, it could be a Repository Dispatch event.

We will configure Crowdin to send this request without any middleware, just by setting up the webhook on a needed event (e.g. File is 100% translated).

Depending on a Crowdin Edition you use, please check the documentation how to create a webhook in crowdin.com and Crowdin Enterprise.

Below is an example of a fully configured Crowdin webhook:

Screenshot

Workflow example:

name: 'crowdin'

on:
  workflow_dispatch:

  repository_dispatch:
    types:
      - file-fully-translated

jobs:
  synchronize-with-crowdin:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: crowdin action 
         uses: crowdin/github-action@1.5.1
         with:
           upload_translations: true
           download_translations: true
         env:
           GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
           CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
           CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

Also, you can access the webhook payload fields in your workflow:

${{ github.event.client_payload.file }}

For more advanced setup please refer to the official documentation.

Crowdin is a platform that helps you manage and translate content into different languages. Integrate Crowdin with your repo, CMS, or other systems. Source content is always up to date for your translators, and translated content is returned automatically.

Learn More
Categories
Development
Tags
git
Works with
  • Crowdin Enterprise
  • crowdin.com
Details

Released on Dec 7, 2022

Updated on Jun 14, 2023

Published by Andrii Bodnar

Identifier:github-actions-webhook