From dceb808edd30c826220b32b1431a7acc76fdcc21 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 5 Apr 2023 11:52:22 +0200 Subject: [PATCH] move l10n helper to danger --- .github/workflows/help-l10n-contributors.yml | 43 -------------------- dangerfile.js | 28 +++++++++++++ 2 files changed, 28 insertions(+), 43 deletions(-) delete mode 100644 .github/workflows/help-l10n-contributors.yml diff --git a/.github/workflows/help-l10n-contributors.yml b/.github/workflows/help-l10n-contributors.yml deleted file mode 100644 index dcb48f2232e3b..0000000000000 --- a/.github/workflows/help-l10n-contributors.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Provide help for l10n PR -on: - pull_request: - types: opened - paths: - - '**/src/locales/**.ts' -jobs: - help-provider: - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Add tag - uses: actions/github-script@v6 - with: - script: | - github.rest.issues.addLabels({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - labels: ["l10n"] - }) - - name: Add comment - uses: peter-evans/create-or-update-comment@a35cf36e5301d70b76f316e867e7788a55a31dae - with: - issue-number: ${{ github.event.pull_request.number }} - comment-author: 'github-actions[bot]' - body: | - Seems you are updating localization :earth_africa: files. - - Thank you for contributing to the localization! :tada: To make your PR perfect, here is a list of elements to check: :heavy_check_mark: - - - [ ] Verify if the PR title respects the release format. Here are two examples (depending if you update or add a locale file) - > [l10n] Improve Swedish (sv-SE) locale - > [l10n] Add Danish (da-DK) locale - - - [ ] Update the documentation of supported locales by running `yarn l10n` - - [ ] Clean files with `yarn prettier` - - If you are **adding** a new locale file, here are other specific steps: - - - [ ] Verify that you have added an export line in `src/locales/index.ts` for the new locale. - - [ ] Run `yarn docs:api` which should add your new translation to the list of exported interfaces. diff --git a/dangerfile.js b/dangerfile.js index f01ad6da01494..5030d4920c784 100644 --- a/dangerfile.js +++ b/dangerfile.js @@ -78,8 +78,36 @@ ${ `); } +function addL10nHelpMessage() { + const isAddingLocale = danger.git.created_files.some((file) => file.includes('/src/locales/')); + const isUpdatingLocale = danger.git.modified_files.some((file) => file.includes('/src/locales/')); + + if (!isAddingLocale && !isUpdatingLocale) { + return; + } + markdown( + [ + 'Seems you are updating localization :earth_africa: files.', + '', + 'Thank you for contributing to the localization! :tada: To make your PR perfect, here is a list of elements to check: :heavy_check_mark:', + '- [ ] Verify if the PR title respects the release format. Here are two examples (depending if you update or add a locale file)', + ' > [l10n] Improve Swedish (sv-SE) locale', + ' > [l10n] Add Danish (da-DK) locale', + '- [ ] Update the documentation of supported locales by running `yarn l10n`', + ...(isAddingLocale + ? [ + '- [ ] Verify that you have added an export line in `src/locales/index.ts` for the new locale.', + '- [ ] Run `yarn docs:api` which should add your new translation to the list of exported interfaces.', + ] + : []), + '- [ ] Clean files with `yarn prettier`.', + ].join('\n'), + ); +} + async function run() { addDeployPreviewUrls(); + addL10nHelpMessage(); switch (dangerCommand) { case 'reportPerformance':