-
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (193 loc) · 7.89 KB
/
Copy pathci-gettext-update-po.yml
File metadata and controls
198 lines (193 loc) · 7.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# Distributed under the OSI-approved BSD 3-Clause License.
# See accompanying file LICENSE-BSD for details.
name: ci-gettext-update-po
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: 'main'
VERSION_GROUP:
description: 'VERSION_GROUP input (for group mode)'
required: true
type: choice
default: 'dev'
options:
- 'dev'
- 'rel'
LANGUAGE:
description: 'LANGUAGE input'
required: true
type: string
default: 'all'
MODE_OF_UPDATE:
description: 'MODE_OF_UPDATE input'
required: true
type: choice
default: 'COMPARE'
options:
- 'COMPARE'
- 'ALWAYS'
- 'NEVER'
jobs:
precondition:
if: ${{ ( github.repository == 'localizethedocs/litestar-docs-l10n' ) &&
( ( github.event_name == 'repository_dispatch' &&
github.event.action == 'pr-merged-to-l10n' &&
github.event.client_payload.GETTEXT == 'true' ) ||
( github.event_name == 'workflow_dispatch' ) ) }}
runs-on: ${{ vars.RUNNER }}
steps:
- name: Print Contexts/Inputs/Variables/Secrets
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 }}" # For 'repository_dispatch' event's type
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 "inputs.LANGUAGE = ${{ inputs.LANGUAGE }}"
echo "inputs.MODE_OF_UPDATE = ${{ inputs.MODE_OF_UPDATE }}"
echo "[Variables]"
echo "vars.RUNNER = ${{ vars.RUNNER }}"
echo "vars.ACTOR_NAME = ${{ vars.ACTOR_NAME }}"
echo "vars.ACTOR_EMAIL = ${{ vars.ACTOR_EMAIL }}"
echo "vars.GPG_FINGERPRINT = ${{ vars.GPG_FINGERPRINT }}"
echo "[Secrets]"
echo "secrets.ACTOR_GITHUB_TOKEN = ${{ secrets.ACTOR_GITHUB_TOKEN }}"
echo "secrets.GPG_PRIVATE_KEY = ${{ secrets.GPG_PRIVATE_KEY }}"
echo "secrets.GPG_PASSPHRASE = ${{ secrets.GPG_PASSPHRASE }}"
- 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.GPG_FINGERPRINT }}" ]]; then
echo "vars.GPG_FINGERPRINT 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.ACTOR_GITHUB_TOKEN }}" ]]; then
echo "secrets.ACTOR_GITHUB_TOKEN is missing."
REQUIRED_SECRETS_EXIST=false
fi
if [[ -z "${{ secrets.GPG_PRIVATE_KEY }}" ]]; then
echo "secrets.GPG_PRIVATE_KEY is missing."
REQUIRED_SECRETS_EXIST=false
fi
if [[ -z "${{ secrets.GPG_PASSPHRASE }}" ]]; then
echo "secrets.GPG_PASSPHRASE 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/litestar-docs-l10n' ) &&
( ( github.event_name == 'repository_dispatch' &&
github.event.action == 'pr-merged-to-l10n' &&
github.event.client_payload.GETTEXT == '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: 'all'
- name: Get LANGUAGE_ARRAY from the languages.json file
id: glal
uses: localizethedocs/ci-common/.github/actions/get-language-array-from-languages-file@main
with:
language: ${{ inputs.LANGUAGE || github.event.client_payload.LANGUAGE }}
- 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-language'
version-array: ${{ steps.gvlv.outputs.VERSION_ARRAY }}
language-array: ${{ steps.glal.outputs.LANGUAGE_ARRAY }}
caller:
needs: [ 'precondition', 'get-matrix' ]
if: ${{ ( github.repository == 'localizethedocs/litestar-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.GETTEXT == 'true' ) ||
( github.event_name == 'workflow_dispatch' ) ) }}
strategy:
matrix: ${{ fromJSON(needs.get-matrix.outputs.MATRIX) }}
fail-fast: false
concurrency:
group: ${{ github.workflow }}-${{ matrix.VERSION }}-${{ matrix.LANGUAGE }}
cancel-in-progress: true
uses: localizethedocs/ci-common/.github/workflows/use-gettext-update-po.yml@main
with:
ENABLE: true
RUNNER: ${{ vars.RUNNER }}
CHECKOUT: ${{ github.ref }}
VERSION: ${{ matrix.VERSION }}
LANGUAGE: ${{ matrix.LANGUAGE }}
MODE_OF_UPDATE: ${{ inputs.MODE_OF_UPDATE || 'COMPARE' }}
ACTOR_NAME: ${{ vars.ACTOR_NAME }}
ACTOR_EMAIL: ${{ vars.ACTOR_EMAIL }}
GPG_FINGERPRINT: ${{ vars.GPG_FINGERPRINT }}
secrets:
ACTOR_GITHUB_TOKEN: ${{ secrets.ACTOR_GITHUB_TOKEN }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}