From 1d616c733ba6e20aa2bb73a7de4ad72496ffa378 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Fri, 24 Mar 2023 00:14:06 -0700 Subject: [PATCH] feat(.github): comment on i18n failure (#49746) Co-authored-by: Shaun Hamilton --- .github/workflows/node.js-tests.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/node.js-tests.yml b/.github/workflows/node.js-tests.yml index 4cac9071e6b..f18b6a0e8f3 100644 --- a/.github/workflows/node.js-tests.yml +++ b/.github/workflows/node.js-tests.yml @@ -218,3 +218,29 @@ jobs: CURRICULUM_LOCALE: ${{ matrix.locale }} CLIENT_LOCALE: ${{ matrix.locale }} run: pnpm test + + failure-comment: + name: Comment on i18n Failure + needs: ['test', 'test-localization'] + runs-on: ubuntu-20.04 + if: ${{ always() && needs.test.result == 'success' && needs.test-localization.result == 'failure' }} + steps: + - uses: actions/github-script@98814c53be79b1d30f795b907e553d8679345975 # v6 + with: + github-token: ${{ secrets.CAMPERBOT_NO_TRANSLATE }} + script: | + const isDev = await github.rest.teams.getMembershipForUserInOrg({ + org: "freeCodeCamp", + team_slug: "dev-team", + username: context.payload.pull_request.user.login + }).catch(() => ({status: 404})); + if (context.payload.pull_request.user.login !== "camperbot" && isDev.status !== 200) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "Hi,\n\nIt looks like the localization tests have failed. This is expected when there are significant curriculum changes in the English version.\n\nThis could mean a Crowdin sync is required to address the scenario. Please check with our staff developer team, either on [Discord](https://discord.gg/KVUmVXA) or our [forums](https://forum.freecodecamp.org). They will confirm and take over helping you through the PR.\n\nThanks for your understanding and contribution." + }) + } else if (isDev.status === 200) { + core.setFailed('This PR appears to touch translated curriculum files, but since you are on the dev team there is no message.'); + }