Skip to content

uigkyfjdthrsef

uigkyfjdthrsef #4

Workflow file for this run

name: Step 3 # Last step of the exercise
on:
pull_request:
types: [opened, reopened, closed]
workflow_dispatch:
permissions:
contents: write
actions: write
issues: write
pull-requests: write
env:
REVIEW_FILE: ".github/steps/x-review.md"
jobs:
find_exercise:
name: Find Exercise Issue
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
on-opened:
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Comment on the PR
uses: GrantBirki/comment@v2.1.1
with:
repository: ${{ github.repository }}
issue-number: ${{ github.event.pull_request.number }}
file: .github/steps/3-step.md
post_review_content:
name: Post review content
needs: [find_exercise]
runs-on: ubuntu-latest
env:
ISSUE_REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create comment - step finished - final review next
uses: GrantBirki/comment@v2.1.1
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: .github/i18n/fr/lesson-review.md
- name: Create comment - add review content
uses: GrantBirki/comment@v2.1.1
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: ${{ env.REVIEW_FILE }}
- name: Disable current workflow
run: gh workflow disable ".github/workflows/3-last-step.yml"
env:
GH_TOKEN: ${{ github.token }}
continue-on-error: true
finish_exercise:
name: Finish Exercise
needs: [find_exercise, post_review_content]
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.7.1
with:
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
exercise-title: "GitHub Basics"
update-readme-with-congratulations: false
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: Update README with final FR block and share links
uses: actions/github-script@v7
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">

Check failure on line 106 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 106
# 🎉 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 !**
[![](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 and push final README
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 "No changes to commit"
else
git commit -m "docs(readme): add final congratulations block 🎉"
fi
git fetch origin main
git pull --rebase origin main || true
git push origin HEAD:main
- name: Replace final EN comment with 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 });
}