Skip to content

Add final congratulations message in English #1

Add final congratulations message in English

Add final congratulations message in English #1

Workflow file for this run

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 !**

Check failure on line 42 in .github/workflows/3-last-step.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/3-last-step.yml

Invalid workflow file

You have an error in your yaml syntax on line 42
<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 !**
[![](https://img.shields.io/badge/Revenir%20%C3%A0%20l%27exercice-%E2%86%92-1f883d?style=for-the-badge&logo=github&labelColor=197935)](${repoUrl}/issues/${process.env.ISSUE_NUMBER})
[![GitHub Skills](https://img.shields.io/badge/D%C3%A9couvrir%20GitHub%20Skills-000000?style=for-the-badge&logo=github&logoColor=white)](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 });
}