1- name : Step 3 # Last step of the exercise
1+ name : Step 4 # Last step of the exercise
22
33on :
44 pull_request :
5- types : [opened, reopened, synchronize, closed]
5+ types : [closed]
66 workflow_dispatch :
77
88permissions :
@@ -13,84 +13,26 @@ permissions:
1313
1414env :
1515 REVIEW_FILE : " .github/steps/x-review.md"
16- STEP_4_FILE : " .github/steps/4-step.md"
1716
1817jobs :
1918 find_exercise :
2019 name : Find Exercise Issue
2120 uses : skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
2221
23- # 1) À l'ouverture/mise à jour de la PR, afficher l'Étape 4 (merge)
24- step4_merge_guidance :
25- name : Step 4, merge guidance
26- needs : [find_exercise]
27- if : ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }}
28- runs-on : ubuntu-latest
29- env :
30- ISSUE_REPOSITORY : ${{ github.repository }}
31- ISSUE_NUMBER : ${{ needs.find_exercise.outputs.issue-number }}
32- steps :
33- - name : Checkout
34- uses : actions/checkout@v4
35-
36- - name : Detect PR mergeability
37- id : prinfo
38- uses : actions/github-script@v7
39- with :
40- script : |
41- const { owner, repo } = context.repo;
42- const number = context.payload.pull_request.number;
43- const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number });
44- core.setOutput('mergeable_state', pr.mergeable_state || 'unknown');
45-
46- - name : Build status line
47- id : status
48- run : |
49- state='${{ steps.prinfo.outputs.mergeable_state }}'
50- if [ "$state" = "clean" ] || [ "$state" = "unstable" ] || [ "$state" = "blocked" ]; then
51- echo "line=✅ Pas de conflit bloquant détecté, tu peux **fusionner** ta PR" >> $GITHUB_OUTPUT
52- elif [ "$state" = "dirty" ]; then
53- echo "line=⚠️ Conflits détectés, suis les étapes ci-dessous pour les résoudre" >> $GITHUB_OUTPUT
54- else
55- echo "line=ℹ️ État de fusion inconnu pour le moment, suis le guide ci-dessous si GitHub indique des conflits" >> $GITHUB_OUTPUT
56- fi
57-
58- - name : Find existing Step 4 comment
59- id : find
60- uses : peter-evans/find-comment@v3
61- with :
62- repository : ${{ env.ISSUE_REPOSITORY }}
63- issue-number : ${{ env.ISSUE_NUMBER }}
64- comment-author : github-actions[bot]
65- body-includes : " ## Étape 4, résoudre les conflits et fusionner"
66-
67- - name : Create or update Step 4 comment
68- uses : GrantBirki/comment@v2.1.1
69- with :
70- repository : ${{ env.ISSUE_REPOSITORY }}
71- issue-number : ${{ env.ISSUE_NUMBER }}
72- file : ${{ env.STEP_4_FILE }}
73- edit-mode : ${{ steps.find.outputs.comment-id && 'replace' || 'append' }}
74- comment-id : ${{ steps.find.outputs.comment-id }}
75- vars : |
76- status_line: ${{ steps.status.outputs.line }}
77-
78- # 2) Au merge, lancer le workflow de fin
7922 finish_exercise :
8023 name : Finish Exercise
8124 needs : [find_exercise]
82- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event. pull_request.merged == true }}
25+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
8326 uses : skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.7.1
8427 with :
8528 issue-url : ${{ needs.find_exercise.outputs.issue-url }}
8629 exercise-title : " GitHub Basics"
8730 update-readme-with-congratulations : false
8831
89- # 3) Remplacer le commentaire "Congratulations..." par une version FR
9032 fr_congrats_comment :
9133 name : Replace official congrats with FR
9234 needs : [find_exercise, finish_exercise]
93- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event. pull_request.merged == true }}
35+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
9436 runs-on : ubuntu-latest
9537 env :
9638 ISSUE_NUMBER : ${{ needs.find_exercise.outputs.issue-number }}
@@ -101,36 +43,28 @@ jobs:
10143 script : |
10244 const {owner, repo} = context.repo;
10345 const issue_number = Number('${{ env.ISSUE_NUMBER }}');
104-
105- // Corps FR de remplacement
10646 const frBody = [
10747 `🎉 Félicitations @${context.actor} tu as terminé l’exercice **GitHub Basics**.`,
10848 `Le dépôt a été mis à jour pour marquer la réussite, et le README affiche un message de félicitations en français.`,
10949 `➡️ Retourne à la page d’accueil du dépôt pour voir le résultat.`
11050 ].join('\n\n');
111-
112- // Cherche le dernier commentaire du bot contenant "Congratulations"
11351 const { data: comments } = await github.rest.issues.listComments({
11452 owner, repo, issue_number, per_page: 100, sort: 'created', direction: 'desc'
11553 });
116-
11754 const target = comments.find(c =>
11855 c.user?.login === 'github-actions[bot]' &&
11956 /Congratulations|You finished the exercise/i.test(c.body || '')
12057 );
121-
12258 if (target) {
12359 await github.rest.issues.updateComment({ owner, repo, comment_id: target.id, body: frBody });
12460 } else {
125- // Par sécurité, si on ne trouve pas le commentaire EN on poste le FR
12661 await github.rest.issues.createComment({ owner, repo, issue_number, body: frBody });
12762 }
12863
129- # 4) Mettre à jour le README avec le bloc de félicitations
13064 finalize_fr :
131- name : Finalize FR
65+ name : Finalize FR README
13266 needs : [find_exercise, finish_exercise, fr_congrats_comment]
133- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event. pull_request.merged == true }}
67+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
13468 runs-on : ubuntu-latest
13569 env :
13670 ISSUE_NUMBER : ${{ needs.find_exercise.outputs.issue-number }}
15589 const shareX = `https://twitter.com/intent/tweet?text=${enc}`;
15690 const shareBsky = `https://bsky.app/intent/compose?text=${enc}`;
15791 const shareLinkedIn = `https://www.linkedin.com/feed/?shareActive=true&text=${enc}`;
158-
15992 const lines = [
16093 '<div align="center">',
16194 '',
@@ -217,42 +150,38 @@ jobs:
217150 git pull --rebase origin main || true
218151 git push origin HEAD:main
219152
220- # 5) Revue finale en FR, publiée après remplacement du message et màj du README
221153 post_review_content :
222- name : Post review content, after merge
154+ name : Post review content (FR)
223155 needs : [find_exercise, fr_congrats_comment, finalize_fr]
224- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event. pull_request.merged == true }}
156+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
225157 runs-on : ubuntu-latest
226158 env :
227159 ISSUE_REPOSITORY : ${{ github.repository }}
228160 ISSUE_NUMBER : ${{ needs.find_exercise.outputs.issue-number }}
229161 steps :
230162 - name : Checkout
231163 uses : actions/checkout@v4
232-
233- - name : Create comment, step finished, final review next
164+ - name : Create comment - step finished - final review next
234165 uses : GrantBirki/comment@v2.1.1
235166 with :
236167 repository : ${{ env.ISSUE_REPOSITORY }}
237168 issue-number : ${{ env.ISSUE_NUMBER }}
238169 file : .github/i18n/fr/lesson-review.md
239-
240- - name : Create comment, add review content
170+ - name : Create comment - add review content
241171 uses : GrantBirki/comment@v2.1.1
242172 with :
243173 repository : ${{ env.ISSUE_REPOSITORY }}
244174 issue-number : ${{ env.ISSUE_NUMBER }}
245175 file : ${{ env.REVIEW_FILE }}
246176
247- # 6) Désactivation une fois tout terminé
248- disable_step3 :
249- name : Disable Step 3
177+ disable_step4 :
178+ name : Disable Step 4
250179 needs : [post_review_content]
251- if : ${{ github.event_name == 'pull_request' && github.event.action == 'closed' && github.event. pull_request.merged == true }}
180+ if : ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true }}
252181 runs-on : ubuntu-latest
253182 steps :
254183 - name : Disable workflow file
255- run : gh workflow disable ".github/workflows/3 -last-step.yml"
184+ run : gh workflow disable ".github/workflows/4 -last-step.yml"
256185 env :
257186 GH_TOKEN : ${{ github.token }}
258187 continue-on-error : true
0 commit comments