-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Crowdin CI v2 #12922
Crowdin CI v2 #12922
Conversation
extract env vars to single-declaration; remove sleep and replace with awaitLatestBuild script; move timing to AM,
this is updated with each import cycle and committed; large number of build minutes and not required here
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
in lieu of incorporation into CI/CD workflow; keeps triggerBuild.ts script
Repeat calls could produce the same build ID. `import "dotenv/config"` not needed when called from an action
Requires getting process.env.BUILD_ID from previous script in workflow (triggerBuild.ts)
OUTPUT=$(npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/translations/triggerBuild.ts) | ||
echo "$OUTPUT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax echo's the console.log
statements made from inside triggerBuild.ts
. Console log statements matching a particular pattern of ::set-output name=key_name::value
can be extracted in a future step.
In triggerBuild.ts
we're console logging ::set-output name=buildId::${id}
which allows us to get the buildId
variable next.
env: | ||
BUILD_ID: ${{ steps.build-crowdin.outputs.buildId}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assigns the buildId
output from the previous step (step id: build-crowdin
) to an environment variable to be accessed by the next script.
OUTPUT=$(npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/translations/awaitLatestBuild.ts) | ||
echo "$OUTPUT" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar syntax to above, but this time we're outputting ::set-output name=buildSuccess::true
(or false) depending if the build eventually switched to "finished" status or not.
run: | | ||
if [ "${{ steps.build-crowdin.outputs.buildSuccess }}" = "false" ]; then | ||
echo "Build timed out, exiting" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the buildSuccess
from the prior step was "false"
the we exit early due to timing out. exit 1
will be treated as a failure, and the workflow will stop here.
- name: Get latest translation bucket directory ids | ||
run: npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/translations/getBucketDirectoryIds.ts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run the script to get the up-to-date bucket directory id's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created this since fetchAndSaveDirectories
does not automatically call this function, and it is used elsewhere so I wanted to avoid conflicting.
import "dotenv/config" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out this isn't needed when running from an action
`Build ${isAlreadyFinished ? "already finished" : "triggered"} id:`, | ||
id | ||
) | ||
console.log(`::set-output name=buildId::${id}`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output id
for use in next workflow step
} | ||
|
||
if (data.status !== FINISHED) { | ||
console.error(`::set-output name=buildSuccess::false`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If fetch has timed out and still not finished, export buildSuccess=false
to terminate workflow early.
.github/workflows/build-crowdin.yml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer needed as a dedicated workflow.
Closing for now in lieu of #12936 |
#12936 attempted to use |
See test job here: https://github.com/ethereum/ethereum-org-website/actions/runs/9157393196/job/25173634077 Generated PRs:
This was executed on a sub-branch, now merged into this branch. |
jobs: | ||
create_approved_language_bucket_prs: | ||
runs-on: ubuntu-latest | ||
env: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved these up to avoid re-declaring for each step.
env: | ||
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }} | ||
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By providing this token, the GitHub CLI will automatically authenticate; have removed the gh auth
step.
id: build-crowdin | ||
run: | | ||
npx ts-node -O '{"module":"commonjs"}' ./src/scripts/crowdin/translations/triggerBuild.ts; | ||
grep BUILD_ID output.env >> $GITHUB_ENV; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the latest recommended way to pass a variable to a future job step. the set-output
approach originally being used here has been deprecated, so I've converted to this approach.
|
||
- name: Check build success | ||
run: | | ||
if [ $(grep BUILD_SUCCESS output.env | cut -d'=' -f2) = false ]; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BUILD_SUCCESS will be "false" if the previous step times-out without a finished build available. exit 1
will terminate the entire workflow with an error in this case.
@@ -60,6 +58,7 @@ export const scrapeDirectory = ( | |||
// Update .md tracker | |||
trackers.langs[repoLangCode].mdCopyCount++ | |||
} else { | |||
if (!statSync(source).isDirectory()) return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This else
block was catching the non-markdown/JSON files (such as .xlsx
) and attempting to open as a directory; this guard clause will skip non-directories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
Description
TODO: