# GitHub Actions

> Trigger a GitHub Actions Workflow when new translations ready

URL: https://store.crowdin.com/github-actions-webhook
Identifier: github-actions-webhook
Category: Development
Type: Guide
Author: Andrii Bodnar

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](https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event) says we should send the following request to trigger the build:

```bash
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](https://docs.github.com/en/developers/webhooks-and-events/webhooks/webhook-events-and-payloads#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](https://support.crowdin.com/webhooks/#adding-webhooks) and [Crowdin Enterprise](https://support.crowdin.com/enterprise/webhooks/#adding-webhooks).

**Below is an example of a fully configured Crowdin webhook**:

![](https://developers.app.crowdin.net/api/media/file/65ceb628-92d9-4a08-ab25-2d0a223bfbcc.png)

**Workflow example**:

```yaml
name: 'crowdin'

on:
  workflow_dispatch:
  repository_dispatch:
    types:
      - file-fully-translated

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

    steps:
      - uses: actions/checkout@v7

      - name: crowdin action
         uses: crowdin/github-action@v3
         with:
           upload_sources: false
           upload_translations: false
           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](https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event).

## Resources

- [Guide](https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#create-a-workflow-dispatch-event)
- [GitHub Crowdin Action](https://store.crowdin.com/github-action)
- [Action Crowdin Contributors](https://store.crowdin.com/action-crowdin-contributors)
- [Crowdin Request Action](https://store.crowdin.com/crowdin-request-action)
