From c8b46d70e3fd44593906e50cbffb75ab5b6ae74f Mon Sep 17 00:00:00 2001 From: IamLizu Date: Fri, 2 Aug 2024 21:39:08 +0600 Subject: [PATCH 1/2] added required permissions --- .github/workflows/translation.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml index 0fbb4cb5dd..2309027350 100644 --- a/.github/workflows/translation.yml +++ b/.github/workflows/translation.yml @@ -30,6 +30,11 @@ on: jobs: check-translation: runs-on: ubuntu-latest + permissions: + contents: read + issues: write + pull-requests: write + steps: - name: Checkout code uses: actions/checkout@v4 From c9604f9f264edbdd262c91ca50b33d1ab616de73 Mon Sep 17 00:00:00 2001 From: IamLizu Date: Fri, 2 Aug 2024 21:39:49 +0600 Subject: [PATCH 2/2] call `addLabels` only when `labelsToAdd` is not empty --- .github/workflows/translation.yml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml index 2309027350..34ba964fc0 100644 --- a/.github/workflows/translation.yml +++ b/.github/workflows/translation.yml @@ -57,9 +57,11 @@ jobs: }); const modifiedLanguages = new Set(files.map(file => file.filename.split('/')[0])); const labelsToAdd = languages.filter(lang => !modifiedLanguages.has(lang)).map(lang => `requires-translation-${lang}`); - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequest.number, - labels: labelsToAdd - }); \ No newline at end of file + if (labelsToAdd.length > 0) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequest.number, + labels: labelsToAdd + }); + } \ No newline at end of file