|
19 | 19 | with: |
20 | 20 | result-encoding: string |
21 | 21 | script: | |
22 | | - // If triggered by the Translation Runner, we can always proceed |
23 | | - if (context.payload.workflow_run.name === 'Translation Runner') { |
24 | | - return 'true'; |
25 | | - } |
26 | | - |
27 | 22 | // Query the jobs of the CI DOC Checker run |
28 | 23 | const { data: jobsData } = await github.rest.actions.listJobsForWorkflowRun({ |
29 | 24 | owner: context.repo.owner, |
@@ -259,9 +254,24 @@ jobs: |
259 | 254 | uses: actions/github-script@v7 |
260 | 255 | with: |
261 | 256 | script: | |
262 | | - github.rest.issues.addLabels({ |
263 | | - owner: context.repo.owner, |
264 | | - repo: context.repo.repo, |
265 | | - issue_number: ${{ steps.pr_number.outputs.pr_number }}, |
266 | | - labels: ['docs-maintainer'] |
267 | | - }); |
| 257 | + try { |
| 258 | + await github.rest.issues.addLabels({ |
| 259 | + owner: context.repo.owner, |
| 260 | + repo: context.repo.repo, |
| 261 | + issue_number: ${{ steps.pr_number.outputs.pr_number }}, |
| 262 | + labels: ['docs-maintainer'] |
| 263 | + }); |
| 264 | + } catch (error) { |
| 265 | + const status = error?.status ?? error?.response?.status; |
| 266 | + const message = String(error?.message ?? '').toLowerCase(); |
| 267 | + const hasAlreadyExistsCode = Array.isArray(error?.response?.data?.errors) |
| 268 | + && error.response.data.errors.some(item => item?.code === 'already_exists'); |
| 269 | +
|
| 270 | + // Ignore only idempotent duplicate-label errors; surface all other failures. |
| 271 | + if (status === 422 && (message.includes('already exists') || hasAlreadyExistsCode)) { |
| 272 | + core.info('docs-maintainer label already exists. Skipping.'); |
| 273 | + return; |
| 274 | + } |
| 275 | +
|
| 276 | + throw error; |
| 277 | + } |
0 commit comments