freeCodeCamp/.github/workflows/no-prs-to-translation.yml

45 lines
2.4 KiB
YAML
Raw Normal View History

name: No translate on GitHub
on:
pull_request_target:
branches:
- 'main'
paths:
- 'curriculum/challenges/**/*.md'
- '!curriculum/challenges/english/**'
- 'client/i18n/locales/**/intro.json'
- 'client/i18n/locales/**/translations.json'
- '!client/i18n/locales/english/**'
- 'docs/i18n/**'
jobs:
has-translation:
runs-on: ubuntu-20.04
steps:
- uses: actions/github-script@v5
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) {
core.setFailed('This PR appears to touch translated curriculum files.')
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Thanks for your pull-request.\n\nWe are no longer accepting changes to the non-English versions of files in parts of this codebase. This pull-request seems to change some of those. Please visit [our contributing guidelines](https://contribute.freecodecamp.org) to learn more about translating freeCodeCamp's resources.\n\nAs always, we value all of your contributions.\n\nHappy contributing!\n\n---\n_**Note:** This message was automatically generated by a bot. If you feel this message is in error or would like help resolving it, feel free to reach us [in our contributor chat](https://chat.freecodecamp.org/channel/contributors)._"
})
} 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.');
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'WAIT! This message serves as a sanity check. You should *only* see this message if the PR was created as part of a Crowdin download action.'
})
}