Skip to content

Commit 8189815

Browse files
committed
feat: add href logic
1 parent 2e2eecf commit 8189815

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

.github/workflows/non-english-warning.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,29 @@ jobs:
1818
exit 1
1919
fi
2020

21-
add_label_and_comment:
21+
check_changes:
2222
needs: check_branch_name
2323
runs-on: ubuntu-latest
24+
outputs:
25+
all_changes_include_href: ${{ steps.check.outputs.all_changes_include_href }}
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v2
29+
- name: Check changes
30+
id: check
31+
run: |
32+
git fetch origin ${{ github.base_ref }}
33+
DIFF=$(git diff --no-ext-diff --unified=0 origin/${{ github.base_ref }}..${{ github.head_ref }} -- 'public/content/translations/**/*.md' 'src/intl/**/*.json' '!src/intl/en/**' | egrep -v '^[-+]href=')
34+
if [[ -z "$DIFF" ]]; then
35+
echo "ALL_CHANGES_INCLUDE_HREF=true" >> $GITHUB_ENV
36+
else
37+
echo "ALL_CHANGES_INCLUDE_HREF=false" >> $GITHUB_ENV
38+
fi
39+
echo "::set-output name=all_changes_include_href::$ALL_CHANGES_INCLUDE_HREF"
40+
41+
add_label_and_comment:
42+
needs: check_changes
43+
runs-on: ubuntu-latest
2444
steps:
2545
- name: Add label and comment
2646
uses: actions/github-script@v5
@@ -30,16 +50,21 @@ jobs:
3050
const prNumber = context.issue.number;
3151
const repo = context.repo;
3252
const prAuthor = context.payload.pull_request.user.login;
53+
const allChangesIncludeHref = '${{ needs.check_changes.outputs.all_changes_include_href }}' === 'true';
54+
const status = allChangesIncludeHref ? 'question ❓' : 'blocked 🛑';
3355
await github.rest.issues.addLabels({
3456
...repo,
3557
issue_number: prNumber,
36-
labels: ['blocked 🛑', 'non-crowdin translation updates']
58+
labels: [status, 'non-crowdin translation updates']
3759
});
60+
const commentWithoutHrefs = `This pull request contains changes to non-English content, which must be handled through the Crowdin platform instead of GitHub.`
61+
const commentWithHrefs = `This pull request contains changes to non-English content files, which may need to be handled through the Crowdin platform instead of GitHub.
62+
If these changes include _only_ changes to link `href` values (or other non-translated string segments), please disregard this message.`
3863
await github.rest.issues.createComment({
3964
...repo,
4065
issue_number: prNumber,
4166
body: `Thank you for your contribution, @${prAuthor}!
42-
This pull request contains changes to non-English content, which must be handled through the Crowdin platform instead of GitHub.
43-
We value your suggestion and request that you check out [how to help us translate](https://ethereum.org/en/contributing/translation-program/#help-us-translate), and suggest these updates directly in [our Crowdin project](https://crowdin.com/project/ethereum-org) where they can be properly reviewed.
67+
${allChangesIncludeHref ? commentWithHrefs : commentWithoutHrefs}
68+
We value your suggestion, and for any non-English content updates we request that you check out [how to help us translate](https://ethereum.org/en/contributing/translation-program/#help-us-translate), and suggest these updates directly in [our Crowdin project](https://crowdin.com/project/ethereum-org) if possible, where they can be properly reviewed.
4469
Please post here or join [our Discord](https://ethereum.org/discord) if you have questions!`
4570
});

0 commit comments

Comments
 (0)