Skip to content

Update the translation issues automatically #251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ jobs:

steps:
- uses: actions/checkout@v1
- run: yarn install

# Update all the translation issues on a nightly basis
- run: node packages/typescriptlang-org/scripts/updateGitHubTranslationIssues.ts
env:
GITHUB_TOKEN: ${{ secrets.TS_BOT_TOKEN }}

# Setup Git
- run: git config user.name "typescript-bot"
- run: git config user.email "[email protected]"
Expand All @@ -21,5 +28,5 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.TS_BOT_TOKEN }}

- run: git commit --no-edit --allow-empty
- run: git commit --allow-empty -m "Nightly Deploy"
- run: git push upstream master:release -f
26 changes: 15 additions & 11 deletions packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ const { join } = require("path")
const fs = require("fs")
const path = require("path")

const lang = process.argv.slice(2)[0]
if (!lang) {
console.log("You need to run this script with a language arg")
console.log(
"> node packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js jp"
)
}

const getAllTODOFiles = () => {
const getAllTODOFiles = lang => {
const diffFolders = (root, lang) => {
const en = join(root, "en")
const thisLang = join(root, lang)
Expand Down Expand Up @@ -111,5 +103,17 @@ const toMarkdown = files => {
return md.join("\n")
}

const files = getAllTODOFiles()
console.log(toMarkdown(files))
if (!module.parent) {
const lang = process.argv.slice(2)[0]
if (!lang) {
console.log("You need to run this script with a language arg")
console.log(
"> node packages/typescriptlang-org/scripts/makeMarkdownOfTranslations.js jp"
)
}

const files = getAllTODOFiles(lang)
console.log(toMarkdown(files))
}

module.exports = { toMarkdown, getAllTODOFiles }
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @ts-check

const nodeFetch = require("node-fetch").default
const { writeFileSync, readFileSync } = require("fs")
const { join } = require("path")
const { getAllTODOFiles, toMarkdown } = require("./makeMarkdownOfTranslations")
const Octokit = require("@octokit/rest")

const languages = {
ja: 220,
pt: 233,
es: 232,
}

const go = async () => {
const octokit = Octokit({
auth: process.env.GITHUB_TOKEN,
userAgent: "TS Lang Issue Updater",
})

const langs = Object.keys(languages)

for (let index = 0; index < langs.length; index++) {
const lang = langs[index]
const issueNumber = languages[lang]

const files = getAllTODOFiles(lang)
const body = toMarkdown(files)

await octokit.issues.update({
owner: "Microsoft",
repo: "TypeScript-Website",
issue_number: issueNumber,
body,
})
}
}

go()