⬆️ upgrade node + use last model version #390
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generates an artifact containing the result of the translations status of the UI. | |
# | |
# TODO: to factorize with the model's CI. | |
name: Generate PR comment | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
push: | |
branches: | |
- '!main' | |
- '!preprod' | |
jobs: | |
compile: | |
runs-on: ubuntu-22.04 | |
outputs: | |
check-ui-result: ${{ steps.check-ui.outputs.result }} | |
check-faq-result: ${{ steps.check-faq.outputs.result }} | |
steps: | |
- uses: actions/checkout@v2 | |
- run: git log | head && git status | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '22' | |
cache: 'yarn' | |
- run: yarn install --immutable | |
shell: bash | |
- run: yarn ui:check | |
- run: yarn faq:check | |
- id: check-ui | |
run: | | |
# Checks the translation of the UI's texts | |
body="$(yarn ui:check --markdown 2> /dev/null | tail --lines=+7 | head --lines=-1)" | |
body="${body//'%'/'%25'}" | |
body="${body//$'\n'/'%0A'}" | |
body="${body//$'\r'/'%0D'}" | |
echo "::set-output name=result::${body}" | |
- id: check-faq | |
run: | | |
# Checks the translation of FAQ's questions | |
body="$(yarn faq:check --markdown 2> /dev/null | tail --lines=+3 | head --lines=-1)" | |
body="${body//'%'/'%25'}" | |
body="${body//$'\n'/'%0A'}" | |
body="${body//$'\r'/'%0D'}" | |
echo "::set-output name=result::${body}" | |
generate-pr-comment: | |
runs-on: ubuntu-22.04 | |
needs: compile | |
steps: | |
- name: Create artifact | |
run: | | |
echo " | |
<h1 align="center">Report for the pull request #${{ github.event.pull_request.number }}</h1> | |
--- | |
### :globe_with_meridians: Translation status | |
#### UI's texts | |
${{ needs.compile.outputs.check-ui-result }} | |
#### FAQ's questions | |
${{ needs.compile.outputs.check-faq-result }} | |
> _You will find more information about the translation in the dedicated file._ | |
" > result.md | |
- name: Updating the PR | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const {owner, repo} = context.repo; | |
const pull_requests = await github.rest.pulls.list(context.repo); | |
if (!pull_requests.data.length) { | |
return core.error("Currently, there is no open PR."); | |
} | |
core.info('Found ' + pull_requests.data.length + ' PR'); | |
const triggered_pr = context.payload.pull_request; | |
if (!triggered_pr) { | |
return core.error('The corresponding PR could not be found.'); | |
} | |
core.info('Found the corresponding PR: #' + triggered_pr.number); | |
const marker = 'yarn-compile-result'; | |
if (!fs.existsSync('result.md')) { | |
return core.info("Cannot find 'result.md', skipping") | |
} | |
var body = '<!-- bot: ' + marker + ' -->\n' + fs.readFileSync('result.md', 'utf8'); | |
const issue_number = triggered_pr.number; | |
const comments = await github.rest.issues.listComments({owner, repo, issue_number}); | |
const existing = comments.data.filter((c) => c.body.includes(marker)); | |
try { | |
if (existing.length > 0) { | |
const last = existing[existing.length - 1]; | |
core.info('Updating the comment ' + last.id); | |
await github.rest.issues.updateComment({ | |
owner, | |
repo, | |
body, | |
comment_id: last.id, | |
}); | |
} else { | |
core.info('Creating a comment in the PR #' + issue_number); | |
await github.rest.issues.createComment({ | |
issue_number, | |
body, | |
owner, | |
repo | |
}); | |
} | |
core.info('PR comment updated/created successfully'); | |
} catch (error) { | |
core.setFailed(`Error updating PR comment: ${error.message}`); | |
} |