Add final congratulations message in English #1
This file contains hidden or 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
| finalize_fr: | ||
| name: Finalize FR | ||
| needs: [find_exercise, post_review_content, finish_exercise] | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| persist-credentials: true | ||
| fetch-depth: 0 | ||
| - name: Mettre à jour README avec bloc FR et liens de partage | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const {owner, repo} = context.repo; | ||
| const login = context.actor; | ||
| const repoUrl = `https://github.com/${owner}/${repo}`; | ||
| const text = `Je viens de terminer l’exercice "GitHub Basics" ! 🎉\n\n${repoUrl}\n\n#GitHubSkills #OpenSource #GitHubLearn`; | ||
| const enc = encodeURIComponent(text); | ||
| const shareX = `https://twitter.com/intent/tweet?text=${enc}`; | ||
| const shareBsky = `https://bsky.app/intent/compose?text=${enc}`; | ||
| const shareLinkedIn = `https://www.linkedin.com/feed/?shareActive=true&text=${enc}`; | ||
| const block = ` | ||
| <div align="center"> | ||
| # 🎉 Félicitations ${login} ! 🎉 | ||
| <img src="https://octodex.github.com/images/welcometocat.png" height="200px" /> | ||
| ### 🌟 Tu as terminé l’exercice avec succès ! 🌟 | ||
| ## 🚀 Partage ta réussite | ||
| **Montre tes nouvelles compétences et inspire les autres !** | ||
| <a href="${shareX}" target="_blank" rel="noopener noreferrer"> | ||
| <img src="https://img.shields.io/badge/Partager%20sur%20X-1da1f2?style=for-the-badge&logo=x&logoColor=white" alt="Partager sur X" /> | ||
| </a> | ||
| <a href="${shareBsky}" target="_blank" rel="noopener noreferrer"> | ||
| <img src="https://img.shields.io/badge/Partager%20sur%20Bluesky-0085ff?style=for-the-badge&logo=bluesky&logoColor=white" alt="Partager sur Bluesky" /> | ||
| </a> | ||
| <a href="${shareLinkedIn}" target="_blank" rel="noopener noreferrer"> | ||
| <img src="https://img.shields.io/badge/Partager%20sur%20LinkedIn-0077b5?style=for-the-badge&logo=linkedin&logoColor=white" alt="Partager sur LinkedIn" /> | ||
| </a> | ||
| ### 🎯 Et maintenant ? | ||
| **Garde l’élan !** | ||
| [](${repoUrl}/issues/${process.env.ISSUE_NUMBER}) | ||
| [](https://learn.github.com/skills) | ||
| *Il n’y a pas de meilleure façon d’apprendre que de construire des choses !* 🚀 | ||
| </div> | ||
| --- | ||
| `.trim() + "\n"; | ||
| const readmePath = path.join(process.env.GITHUB_WORKSPACE, 'README.md'); | ||
| const current = fs.existsSync(readmePath) ? fs.readFileSync(readmePath, 'utf8') : ''; | ||
| fs.writeFileSync(readmePath, `${block}${current}`, 'utf8'); | ||
| - name: Commit et push du README final FR | ||
| shell: bash | ||
| env: | ||
| GIT_AUTHOR_NAME: github-actions[bot] | ||
| GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | ||
| GIT_COMMITTER_NAME: github-actions[bot] | ||
| GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com | ||
| run: | | ||
| set -e | ||
| git add README.md | ||
| if git diff --cached --quiet; then | ||
| echo "Aucun changement à committer" | ||
| else | ||
| git commit -m "docs(readme): félicitations finales en français" | ||
| fi | ||
| git fetch origin main | ||
| git pull --rebase origin main || true | ||
| git push origin HEAD:main | ||
| - name: Remplacer le commentaire final EN par FR | ||
| uses: actions/github-script@v7 | ||
| env: | ||
| ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} | ||
| with: | ||
| script: | | ||
| const {owner, repo} = context.repo; | ||
| const issue_number = Number(process.env.ISSUE_NUMBER); | ||
| const body = [ | ||
| `🎉 Félicitations @${context.actor} tu as terminé l’exercice **GitHub Basics**.`, | ||
| `Le README a été mis à jour avec un message final en français.`, | ||
| `➡️ Retourne à la page d’accueil du dépôt pour voir le résultat.` | ||
| ].join('\n\n'); | ||
| const { data: comments } = await github.rest.issues.listComments({ | ||
| owner, repo, issue_number, per_page: 100, sort: 'created', direction: 'desc' | ||
| }); | ||
| const target = comments.find(c => | ||
| c.user?.login === 'github-actions[bot]' && | ||
| /Congratulations|You finished the exercise/i.test(c.body || '') | ||
| ); | ||
| if (target) { | ||
| await github.rest.issues.updateComment({ owner, repo, comment_id: target.id, body }); | ||
| } else { | ||
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | ||
| } | ||