fix: unhide this string (#43292)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Nicholas Carrigan (he/him)
2021-08-25 20:02:10 -07:00
committed by GitHub
parent 2255c9b544
commit 3ed507a817
3 changed files with 55 additions and 0 deletions

View File

@ -71,3 +71,13 @@ jobs:
CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/' CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/'
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }} CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}
- name: Unhide Title of Use && For a More Concise Conditional
uses: ./tools/crowdin/actions/unhide-specific-string
with:
filename: 'react/use--for-a-more-concise-conditional.md'
string-content: 'Use &amp;&amp; for a More Concise Conditional'
env:
CROWDIN_API_URL: 'https://freecodecamp.crowdin.com/api/v2/'
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID_CURRICULUM }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_CAMPERBOT_SERVICE_TOKEN }}

View File

@ -0,0 +1,12 @@
name: 'Unhide Specific String'
description: "Updates a specific string to be not hidden"
runs:
using: 'node12'
main: './index.js'
inputs:
filename:
description: 'name of file with specific string to hide'
required: true
string-content:
description: 'text content of string to unhide'
required: true

View File

@ -0,0 +1,33 @@
require('dotenv').config({ path: `${__dirname}/../../.env` });
const core = require('@actions/core');
const { getFiles } = require('../../utils/files');
const { getStrings, changeHiddenStatus } = require('../../utils/strings');
const filename = core.getInput('filename');
const stringContent = core.getInput('string-content');
const hideString = async (projectId, fileName, string) => {
const fileResponse = await getFiles(projectId);
const targetFile = fileResponse.find(el => el.path.endsWith(filename));
if (!targetFile) {
core.setFailed(`${fileName} was not found.`);
return;
}
const stringResponse = await getStrings({
projectId,
fileId: targetFile.fileId
});
const targetString = stringResponse.find(el => el.data.text === string);
if (!targetString) {
core.setFailed(`${string} was not found.`);
return;
}
await changeHiddenStatus(projectId, targetString.data.id, false);
console.log('string unhidden!');
};
const projectId = process.env.CROWDIN_PROJECT_ID;
hideString(projectId, filename, stringContent);