Skip to content

Commit ecb076f

Browse files
committed
mlkjhgfd
1 parent a8c1ee0 commit ecb076f

3 files changed

Lines changed: 117 additions & 98 deletions

File tree

.github/workflows/2-step.yml

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches: [ my-first-branch ]
77
paths:
88
- "playground/**"
9+
# Déclencheur manuel en secours
910
workflow_dispatch:
1011

1112
permissions:
@@ -17,24 +18,34 @@ permissions:
1718
env:
1819
STEP_3_FILE: ".github/steps/3-step.md"
1920

21+
concurrency:
22+
group: ${{ github.workflow }}-${{ github.ref }}
23+
cancel-in-progress: true
24+
2025
jobs:
2126
find_exercise:
2227
name: Find Exercise Issue
2328
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
2429

25-
# "Grading" pour vérifier le travail
30+
# "Grading" pour vérifier le travail de l'étape 2
2631
check_step_work:
2732
name: Check step work
2833
runs-on: ubuntu-latest
2934
needs: [find_exercise]
3035
env:
3136
ISSUE_REPOSITORY: ${{ github.repository }}
3237
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
33-
3438
steps:
3539
- name: Checkout
3640
uses: actions/checkout@v4
3741

42+
- name: Get response templates
43+
uses: actions/checkout@v4
44+
with:
45+
repository: skills/exercise-toolkit
46+
path: exercise-toolkit
47+
ref: v0.7.1
48+
3849
- name: Find last comment
3950
id: find-last-comment
4051
uses: peter-evans/find-comment@v3
@@ -49,10 +60,10 @@ jobs:
4960
repository: ${{ env.ISSUE_REPOSITORY }}
5061
issue-number: ${{ env.ISSUE_NUMBER }}
5162
comment-id: ${{ steps.find-last-comment.outputs.comment-id }}
52-
file: .github/i18n/fr/checking-work.md
63+
file: exercise-toolkit/markdown-templates/step-feedback/checking-work.md
5364
edit-mode: replace
5465

55-
# START: Checks
66+
# Vérifications de l'exercice
5667
- name: Check if playground/README.md exists
5768
id: check-file-exists
5869
continue-on-error: true
@@ -75,28 +86,27 @@ jobs:
7586
issue-number: ${{ env.ISSUE_NUMBER }}
7687
comment-id: ${{ steps.find-last-comment.outputs.comment-id }}
7788
edit-mode: replace
78-
file: .github/i18n/fr/step-results-table.md
89+
file: exercise-toolkit/markdown-templates/step-feedback/step-results-table.md
7990
vars: |
8091
step_number: 2
8192
results_table:
8293
- description: "Vérifier que playground/README.md existe"
8394
passed: ${{ steps.check-file-exists.outcome == 'success' }}
84-
- description: "Chercher le mot 'Hello' dans playground/README.md"
95+
- description: "Chercher 'Hello' dans playground/README.md"
8596
passed: ${{ steps.check-for-keyphrase.outcome == 'success' }}
86-
# END: Checks
8797
8898
- name: Fail job if not all checks passed
8999
if: contains(steps.*.outcome, 'failure')
90100
run: exit 1
91101

92102
post_next_step_content:
93103
name: Post next step content
94-
needs: [find_exercise, check_step_work]
104+
# Si tu veux bloquer la progression tant que les checks ne passent pas, remplace needs par: [find_exercise, check_step_work]
105+
needs: [find_exercise]
95106
runs-on: ubuntu-latest
96107
env:
97108
ISSUE_REPOSITORY: ${{ github.repository }}
98109
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
99-
100110
steps:
101111
- name: Checkout
102112
uses: actions/checkout@v4
@@ -106,7 +116,7 @@ jobs:
106116
with:
107117
repository: ${{ env.ISSUE_REPOSITORY }}
108118
issue-number: ${{ env.ISSUE_NUMBER }}
109-
file: .github/i18n/fr/step-finished-prepare-next-step.md
119+
file: exercise-toolkit/markdown-templates/step-feedback/step-finished-prepare-next-step.md
110120
vars: |
111121
next_step_number: 3
112122
@@ -122,11 +132,12 @@ jobs:
122132
with:
123133
repository: ${{ env.ISSUE_REPOSITORY }}
124134
issue-number: ${{ env.ISSUE_NUMBER }}
125-
file: .github/i18n/fr/watching-for-progress.md
135+
file: exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
126136

127137
- name: Disable current workflow and enable next one
128138
run: |
129-
gh workflow disable "${{ github.workflow }}"
130-
gh workflow enable ".github/workflows/3-last-step.yml"
139+
gh workflow disable ".github/workflows/2-step.yml"
140+
gh workflow enable ".github/workflows/3-step.yml"
131141
env:
132142
GH_TOKEN: ${{ github.token }}
143+
continue-on-error: true

.github/workflows/3-step.yml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Step 3
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
actions: write
11+
issues: write
12+
pull-requests: write
13+
14+
env:
15+
STEP_4_FILE: ".github/steps/4-step.md"
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
find_exercise:
23+
name: Find Exercise Issue
24+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
25+
26+
step4_merge_guidance:
27+
name: Post Step 4 (merge/conflicts) guidance
28+
needs: [find_exercise]
29+
runs-on: ubuntu-latest
30+
if: ${{ github.event_name == 'pull_request' }}
31+
env:
32+
ISSUE_REPOSITORY: ${{ github.repository }}
33+
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
34+
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v4
38+
39+
- name: Detect PR mergeability
40+
id: prinfo
41+
uses: actions/github-script@v7
42+
with:
43+
script: |
44+
const { owner, repo } = context.repo;
45+
const number = context.payload.pull_request.number;
46+
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: number });
47+
core.setOutput('mergeable_state', pr.mergeable_state || 'unknown');
48+
49+
- name: Build status line
50+
id: status
51+
run: |
52+
state='${{ steps.prinfo.outputs.mergeable_state }}'
53+
if [ "$state" = "clean" ] || [ "$state" = "unstable" ] || [ "$state" = "blocked" ]; then
54+
echo "line=✅ Pas de conflit bloquant détecté, tu peux **fusionner** ta PR" >> $GITHUB_OUTPUT
55+
elif [ "$state" = "dirty" ]; then
56+
echo "line=⚠️ Conflits détectés, suis les étapes ci-dessous pour les résoudre" >> $GITHUB_OUTPUT
57+
else
58+
echo "line=ℹ️ État de fusion inconnu pour le moment, suis le guide ci-dessous si GitHub indique des conflits" >> $GITHUB_OUTPUT
59+
fi
60+
61+
- name: Find existing Step 4 comment
62+
id: find
63+
uses: peter-evans/find-comment@v3
64+
with:
65+
repository: ${{ env.ISSUE_REPOSITORY }}
66+
issue-number: ${{ env.ISSUE_NUMBER }}
67+
comment-author: github-actions[bot]
68+
body-includes: "## Étape 4, résoudre les conflits et fusionner"
69+
70+
- name: Create or update Step 4 comment
71+
uses: GrantBirki/comment@v2.1.1
72+
with:
73+
repository: ${{ env.ISSUE_REPOSITORY }}
74+
issue-number: ${{ env.ISSUE_NUMBER }}
75+
file: ${{ env.STEP_4_FILE }}
76+
edit-mode: ${{ steps.find.outputs.comment-id && 'replace' || 'append' }}
77+
comment-id: ${{ steps.find.outputs.comment-id }}
78+
vars: |
79+
status_line: ${{ steps.status.outputs.line }}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Step 3 # Last step of the exercise
1+
name: Step 4 # Last step of the exercise
22

33
on:
44
pull_request:
5-
types: [opened, reopened, synchronize, closed]
5+
types: [closed]
66
workflow_dispatch:
77

88
permissions:
@@ -13,84 +13,26 @@ permissions:
1313

1414
env:
1515
REVIEW_FILE: ".github/steps/x-review.md"
16-
STEP_4_FILE: ".github/steps/4-step.md"
1716

1817
jobs:
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 }}
@@ -155,7 +89,6 @@ jobs:
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

Comments
 (0)