feat(tools): Add Crowdin PR creator action (#41383)
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
This commit is contained in:
@@ -84,62 +84,21 @@ jobs:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CLIENT }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
|
||||
|
||||
- name: Install Dependencies
|
||||
working-directory: ./tools
|
||||
run: |
|
||||
cd ./crowdin
|
||||
npm ci
|
||||
|
||||
# Generate PR - all languages should go ABOVE this. #
|
||||
- name: Create PR
|
||||
uses: actions/github-script@v3
|
||||
uses: ./tools/crowdin/actions/pr-creator
|
||||
with:
|
||||
github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
|
||||
script: |
|
||||
const branchExists = await github.repos.getBranch({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
branch: 'i18n-sync-client'
|
||||
}).catch(err => {
|
||||
console.info("Branch does not exist. Likely no changes in download?");
|
||||
});
|
||||
if (!branchExists || branchExists.status !== 200) {
|
||||
return;
|
||||
}
|
||||
const pullRequestExists = await github.pulls.list({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'freeCodeCamp:i18n-sync-client'
|
||||
});
|
||||
if (pullRequestExists.data.length) {
|
||||
console.info("It looks like a pull request already exists for this branch.");
|
||||
return;
|
||||
}
|
||||
const PR = await github.pulls.create({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'i18n-sync-client',
|
||||
base: 'main',
|
||||
title: 'chore(i18n,client): processed translations',
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
}).catch(err => {
|
||||
console.info("Unpredicted error occurred when trying to create the PR.");
|
||||
console.error(err);
|
||||
});
|
||||
if (!PR || PR.status !== 201) {
|
||||
return;
|
||||
}
|
||||
const PRNumber = PR.data.number;
|
||||
await github.issues.addLabels({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
issue_number: PRNumber,
|
||||
labels: [
|
||||
"crowdin-sync",
|
||||
"scope: i18n",
|
||||
"scope: UI"
|
||||
]
|
||||
});
|
||||
await github.pulls.requestReviewers({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
pull_number: PRNumber,
|
||||
reviewers: [
|
||||
'RandellDawson',
|
||||
'nhcarrigan'
|
||||
]
|
||||
});
|
||||
branch: 'i18n-sync-client'
|
||||
owner-repo: 'freeCodeCamp/freeCodeCamp'
|
||||
base: 'main'
|
||||
title: 'chore(i18n,client): processed translations'
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
labels: 'crowdin-sync, scope: i18n, scope: UI'
|
||||
reviewers: 'RandellDawson, nhcarrigan'
|
||||
|
@@ -85,62 +85,21 @@ jobs:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
|
||||
|
||||
- name: Install Dependencies
|
||||
working-directory: ./tools
|
||||
run: |
|
||||
cd ./crowdin
|
||||
npm ci
|
||||
|
||||
# Generate PR - all languages should go ABOVE this. #
|
||||
- name: Create PR
|
||||
uses: actions/github-script@v3
|
||||
uses: ./tools/crowdin/actions/pr-creator
|
||||
with:
|
||||
github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
|
||||
script: |
|
||||
const branchExists = await github.repos.getBranch({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
branch: 'i18n-sync-learn'
|
||||
}).catch(err => {
|
||||
console.info("Branch does not exist. Likely no changes in download?");
|
||||
});
|
||||
if (!branchExists || branchExists.status !== 200) {
|
||||
return;
|
||||
}
|
||||
const pullRequestExists = await github.pulls.list({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'freeCodeCamp:i18n-sync-learn'
|
||||
});
|
||||
if (pullRequestExists.data.length) {
|
||||
console.info("It looks like a pull request already exists for this branch.");
|
||||
return;
|
||||
}
|
||||
const PR = await github.pulls.create({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'i18n-sync-learn',
|
||||
base: 'main',
|
||||
title: 'chore(i18n,learn): processed translations',
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
}).catch(err => {
|
||||
console.info("Unpredicted error occurred when trying to create the PR.");
|
||||
console.error(err);
|
||||
});
|
||||
if (!PR || PR.status !== 201) {
|
||||
return;
|
||||
}
|
||||
const PRNumber = PR.data.number;
|
||||
await github.issues.addLabels({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
issue_number: PRNumber,
|
||||
labels: [
|
||||
"crowdin-sync",
|
||||
"scope: i18n",
|
||||
"scope: learn"
|
||||
]
|
||||
});
|
||||
await github.pulls.requestReviewers({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
pull_number: PRNumber,
|
||||
reviewers: [
|
||||
'RandellDawson',
|
||||
'nhcarrigan'
|
||||
]
|
||||
});
|
||||
branch: 'i18n-sync-learn'
|
||||
owner-repo: 'freeCodeCamp/freeCodeCamp'
|
||||
base: 'main'
|
||||
title: 'chore(i18n,learn): processed translations',
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
labels: 'crowdin-sync, scope: i18n, scope: learn'
|
||||
reviewers: 'RandellDawson, nhcarrigan'
|
||||
|
@@ -118,62 +118,21 @@ jobs:
|
||||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_DOCS }}
|
||||
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
|
||||
|
||||
- name: Install Dependencies
|
||||
working-directory: ./tools
|
||||
run: |
|
||||
cd ./crowdin
|
||||
npm ci
|
||||
|
||||
# Generate PR - all languages should go ABOVE this. #
|
||||
- name: Create PR
|
||||
uses: actions/github-script@v3
|
||||
uses: ./tools/crowdin/actions/pr-creator
|
||||
with:
|
||||
github-token: ${{ secrets.CROWDIN_CAMPERBOT_PAT }}
|
||||
script: |
|
||||
const branchExists = await github.repos.getBranch({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
branch: 'i18n-sync-docs'
|
||||
}).catch(err => {
|
||||
console.info("Branch does not exist. Likely no changes in download?");
|
||||
});
|
||||
if (!branchExists || branchExists.status !== 200) {
|
||||
return;
|
||||
}
|
||||
const pullRequestExists = await github.pulls.list({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'freeCodeCamp:i18n-sync-docs'
|
||||
});
|
||||
if (pullRequestExists.data.length) {
|
||||
console.info("It looks like a pull request already exists for this branch.");
|
||||
return;
|
||||
}
|
||||
const PR = await github.pulls.create({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
head: 'i18n-sync-docs',
|
||||
base: 'main',
|
||||
title: 'chore(i18n,docs): processed translations',
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
}).catch(err => {
|
||||
console.info("Unpredicted error occurred when trying to create the PR.");
|
||||
console.error(err);
|
||||
});
|
||||
if (!PR || PR.status !== 201) {
|
||||
return;
|
||||
}
|
||||
const PRNumber = PR.data.number;
|
||||
await github.issues.addLabels({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
issue_number: PRNumber,
|
||||
labels: [
|
||||
"crowdin-sync",
|
||||
"scope: i18n",
|
||||
"scope: docs"
|
||||
]
|
||||
});
|
||||
await github.pulls.requestReviewers({
|
||||
owner: 'freeCodeCamp',
|
||||
repo: 'freeCodeCamp',
|
||||
pull_number: PRNumber,
|
||||
reviewers: [
|
||||
'RandellDawson',
|
||||
'nhcarrigan'
|
||||
]
|
||||
});
|
||||
branch: 'i18n-sync-docs'
|
||||
owner-repo: 'freeCodeCamp/freeCodeCamp'
|
||||
base: 'main'
|
||||
title: 'chore(i18n,docs): processed translations',
|
||||
body: 'This PR was opened auto-magically by Crowdin.'
|
||||
labels: 'crowdin-sync, scope: i18n, scope: docs'
|
||||
reviewers: 'RandellDawson, nhcarrigan'
|
||||
|
Reference in New Issue
Block a user