pr-merged-to-l10n #110
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Distributed under the OSI-approved BSD 3-Clause License. | |
| # See accompanying file LICENSE-BSD for details. | |
| name: ci-crowdin-upload-pot | |
| on: | |
| # Triggers the workflow when a pull request is merged to the 'l10n' branch. | |
| repository_dispatch: | |
| types: | |
| - pr-merged-to-l10n | |
| # Triggers the workflow manually through the GitHub UI. | |
| workflow_dispatch: | |
| inputs: | |
| MODE: | |
| description: 'MODE input' | |
| required: true | |
| type: choice | |
| default: 'group' | |
| options: | |
| - 'single' | |
| - 'group' | |
| VERSION: | |
| description: 'VERSION input (for single mode)' | |
| required: true | |
| type: string | |
| default: 'rolling' | |
| VERSION_GROUP: | |
| description: 'VERSION_GROUP input (for group mode)' | |
| required: true | |
| type: choice | |
| default: 'dev' | |
| options: | |
| - 'dev' | |
| - 'rel' | |
| jobs: | |
| precondition: | |
| if: ${{ ( github.repository == 'localizethedocs/ros2-docs-l10n' ) && | |
| ( ( github.event_name == 'repository_dispatch' && | |
| github.event.action == 'pr-merged-to-l10n' && | |
| github.event.client_payload.CROWDIN == 'true' ) || | |
| ( github.event_name == 'workflow_dispatch' ) ) }} | |
| runs-on: ${{ vars.RUNNER }} | |
| steps: | |
| - name: Print Contexts/Inputs | |
| shell: bash | |
| run: | | |
| echo "[Contexts]" | |
| echo "github.job = ${{ github.job }}" | |
| echo "github.ref = ${{ github.ref }}" | |
| echo "github.ref_name = ${{ github.ref_name }}" | |
| echo "github.event_name = ${{ github.event_name }}" | |
| echo "github.event.action = ${{ github.event.action }}" | |
| echo "github.event.client_payload.MODE = ${{ github.event.client_payload.MODE }}" | |
| echo "github.event.client_payload.VERSION = ${{ github.event.client_payload.VERSION }}" | |
| echo "github.event.client_payload.LANGUAGE = ${{ github.event.client_payload.LANGUAGE }}" | |
| echo "github.event.client_payload.GETTEXT = ${{ github.event.client_payload.GETTEXT }}" | |
| echo "github.event.client_payload.CROWDIN = ${{ github.event.client_payload.CROWDIN }}" | |
| echo "[Inputs]" | |
| echo "inputs.MODE = ${{ inputs.MODE }}" | |
| echo "inputs.VERSION = ${{ inputs.VERSION }}" | |
| echo "inputs.VERSION_GROUP = ${{ inputs.VERSION_GROUP }}" | |
| echo "[Variables]" | |
| echo "vars.RUNNER = ${{ vars.RUNNER }}" | |
| echo "vars.ACTOR_NAME = ${{ vars.ACTOR_NAME }}" | |
| echo "vars.ACTOR_EMAIL = ${{ vars.ACTOR_EMAIL }}" | |
| echo "vars.CROWDIN_PROJECT_ID = ${{ vars.CROWDIN_PROJECT_ID }}" | |
| echo "vars.CROWDIN_BASE_URL = ${{ vars.CROWDIN_BASE_URL }}" | |
| echo "[Secrets]" | |
| echo "secrets.CROWDIN_PERSONAL_TOKEN = ${{ secrets.CROWDIN_PERSONAL_TOKEN }}" | |
| - name: Check Required Variables | |
| shell: bash | |
| run: | | |
| REQUIRED_VARIABLES_EXIST=true | |
| if [[ -z "${{ vars.RUNNER }}" ]]; then | |
| echo "vars.RUNNER is missing." | |
| REQUIRED_VARIABLES_EXIST=false | |
| fi | |
| if [[ -z "${{ vars.ACTOR_NAME }}" ]]; then | |
| echo "vars.ACTOR_NAME is missing." | |
| REQUIRED_VARIABLES_EXIST=false | |
| fi | |
| if [[ -z "${{ vars.ACTOR_EMAIL }}" ]]; then | |
| echo "vars.ACTOR_EMAIL is missing." | |
| REQUIRED_VARIABLES_EXIST=false | |
| fi | |
| if [[ -z "${{ vars.CROWDIN_PROJECT_ID }}" ]]; then | |
| echo "vars.CROWDIN_PROJECT_ID is missing." | |
| REQUIRED_VARIABLES_EXIST=false | |
| fi | |
| if [[ -z "${{ vars.CROWDIN_BASE_URL }}" ]]; then | |
| echo "vars.CROWDIN_BASE_URL is missing." | |
| REQUIRED_VARIABLES_EXIST=false | |
| fi | |
| if [[ "${REQUIRED_VARIABLES_EXIST}" == "false" ]]; then | |
| echo "Error: Some variables are missing." >&2 | |
| exit 1 | |
| fi | |
| - name: Check Required Secrets | |
| shell: bash | |
| run: | | |
| REQUIRED_SECRETS_EXIST=true | |
| if [[ -z "${{ secrets.CROWDIN_PERSONAL_TOKEN }}" ]]; then | |
| echo "secrets.CROWDIN_PERSONAL_TOKEN is missing." | |
| REQUIRED_SECRETS_EXIST=false | |
| fi | |
| if [[ "${REQUIRED_SECRETS_EXIST}" == "false" ]]; then | |
| echo "Error: Some secrets are missing." >&2 | |
| exit 1 | |
| fi | |
| get-matrix: | |
| if: ${{ ( github.repository == 'localizethedocs/ros2-docs-l10n' ) && | |
| ( ( github.event_name == 'repository_dispatch' && | |
| github.event.action == 'pr-merged-to-l10n' && | |
| github.event.client_payload.CROWDIN == 'true' ) || | |
| ( github.event_name == 'workflow_dispatch' ) ) }} | |
| runs-on: ${{ vars.RUNNER }} | |
| outputs: | |
| MATRIX: ${{ steps.gmja.outputs.MATRIX }} | |
| MATRIX_NUM: ${{ steps.gmja.outputs.MATRIX_NUM }} | |
| steps: | |
| - name: Checkout to '${{ github.ref }}' | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.ref }} | |
| submodules: false | |
| - name: Get VERSION_ARRAY from the versions.json file | |
| id: gvlv | |
| uses: localizethedocs/ci-common/.github/actions/get-version-array-from-versions-file@main | |
| with: | |
| mode: ${{ inputs.MODE || github.event.client_payload.MODE }} | |
| version: ${{ inputs.VERSION || github.event.client_payload.VERSION }} | |
| version-group: ${{ inputs.VERSION_GROUP }} | |
| version-filter: 'crowdin' | |
| - name: Get MATRIX from the JSON Arraies | |
| id: gmja | |
| uses: localizethedocs/ci-common/.github/actions/get-matrix-from-json-arraies@main | |
| with: | |
| matrix-type: 'version' | |
| version-array: ${{ steps.gvlv.outputs.VERSION_ARRAY }} | |
| caller: | |
| needs: [ 'precondition', 'get-matrix' ] | |
| if: ${{ ( github.repository == 'localizethedocs/ros2-docs-l10n' ) && | |
| ( needs.get-matrix.outputs.MATRIX_NUM != '0' ) && | |
| ( ( github.event_name == 'repository_dispatch' && | |
| github.event.action == 'pr-merged-to-l10n' && | |
| github.event.client_payload.CROWDIN == 'true' ) || | |
| ( github.event_name == 'workflow_dispatch' ) ) }} | |
| strategy: | |
| matrix: ${{ fromJSON(needs.get-matrix.outputs.MATRIX) }} | |
| fail-fast: false | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ matrix.VERSION }} | |
| cancel-in-progress: true | |
| uses: localizethedocs/ci-common/.github/workflows/use-crowdin-upload-pot.yml@main | |
| with: | |
| ENABLE: true | |
| RUNNER: ${{ vars.RUNNER }} | |
| CHECKOUT: ${{ github.ref }} | |
| VERSION: ${{ matrix.VERSION }} | |
| ACTOR_NAME: ${{ vars.ACTOR_NAME }} | |
| ACTOR_EMAIL: ${{ vars.ACTOR_EMAIL }} | |
| CROWDIN_PROJECT_ID: ${{ vars.CROWDIN_PROJECT_ID }} | |
| CROWDIN_BASE_URL: ${{ vars.CROWDIN_BASE_URL }} | |
| secrets: | |
| ACTOR_GITHUB_TOKEN: ${{ secrets.ACTOR_GITHUB_TOKEN }} | |
| CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }} |