Skip to content

Commit 1278bf0

Browse files
committed
Refactor workflows to improve clarity and localization, including French comments and README updates
1 parent 7c05936 commit 1278bf0

5 files changed

Lines changed: 75 additions & 58 deletions

File tree

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
## Étape {{ step_number }} : Résultats
22

33
| Statut | Description |
4-
| :----: | :---------- |
5-
4+
| :---: | :-- |
65
{% for r in results_table %}
76
{% if r.passed %}| ✅ Réussi | {{ r.description }} |
87
{% else %}| ❌ À corriger | {{ r.description }} |
98
{% endif %}
109
{% endfor %}
11-

.github/workflows/0-start-exercise.yml

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ on:
66
branches: [ main ]
77
# En complément, si la branche par défaut est créée sans commit
88
create:
9-
# Garde le déclencheur manuel en secours
9+
# Déclencheur manuel de secours
1010
workflow_dispatch:
1111

1212
permissions:
1313
contents: write
1414
issues: write
15-
pull-requests: write # si tu veux commenter sur les PR
16-
actions: write # si tu utilises gh workflow enable/disable
15+
pull-requests: write
16+
actions: write
17+
1718
env:
1819
STEP_1_FILE: ".github/steps/1-step.md"
1920

@@ -38,33 +39,9 @@ jobs:
3839
steps:
3940
- name: Checkout
4041
uses: actions/checkout@v4
41-
42-
- name: Remplacer le corps de l’issue par la version FR
43-
uses: actions/github-script@v7
44-
env:
45-
ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }}
4642
with:
47-
script: |
48-
const {owner, repo} = context.repo;
49-
const number = process.env.ISSUE_NUMBER;
50-
const body = [
51-
"👋 Salut @" + context.actor + " ! Bienvenue dans ton exercice **GitHub Skills**.",
52-
"",
53-
"Bienvenue, cette issue va te guider pas à pas dans le cours.",
54-
"",
55-
"✨ Il s'agit d'un exercice GitHub Skills interactif et pratique.",
56-
"",
57-
"Au fil des étapes, je publierai des mises à jour dans les commentaires :",
58-
"",
59-
"✅ Vérifier ton travail et t’indiquer la suite ",
60-
"💡 Partager des conseils et des ressources ",
61-
"🚀 Célébrer ta progression et la fin",
62-
"",
63-
"C'est parti, amuse-toi bien !",
64-
"",
65-
"Mona"
66-
].join('\n');
67-
await github.rest.issues.update({ owner, repo, issue_number: Number(number), body });
43+
persist-credentials: true
44+
fetch-depth: 0
6845

6946
- name: Create comment - add step content
7047
uses: GrantBirki/comment@v2.1.1
@@ -98,13 +75,54 @@ jobs:
9875
env:
9976
README_CONTENT: ${{ steps.build-readme-fr.outputs.updated-text }}
10077

101-
- name: Commit README.md
102-
uses: stefanzweifel/git-auto-commit-action@v5
78+
- name: Commit README.md (FR) avec rebase auto
79+
shell: bash
80+
env:
81+
GIT_AUTHOR_NAME: github-actions[bot]
82+
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
83+
GIT_COMMITTER_NAME: github-actions[bot]
84+
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
85+
run: |
86+
set -e
87+
BRANCH="${GITHUB_REF_NAME:-main}"
88+
git add README.md
89+
if git diff --cached --quiet; then
90+
echo "Aucun changement à committer"
91+
else
92+
git commit -m "docs(readme): version FR pour l’intro"
93+
fi
94+
git fetch origin "$BRANCH"
95+
git pull --rebase origin "$BRANCH" || true
96+
git push origin "HEAD:$BRANCH"
97+
98+
- name: Remplacer le corps de l’issue par la version FR
99+
uses: actions/github-script@v7
100+
env:
101+
ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }}
103102
with:
104-
commit_message: "docs(readme): version FR pour l’intro"
105-
file_pattern: README.md
103+
script: |
104+
const {owner, repo} = context.repo;
105+
const number = Number(process.env.ISSUE_NUMBER);
106+
const body = [
107+
"👋 Salut @" + context.actor + " ! Bienvenue dans ton exercice **GitHub Skills**.",
108+
"",
109+
"Bienvenue, cette issue va te guider pas à pas dans le cours.",
110+
"",
111+
"✨ Il s'agit d'un exercice GitHub Skills interactif et pratique.",
112+
"",
113+
"Au fil des étapes, je publierai des mises à jour dans les commentaires :",
114+
"",
115+
"✅ Vérifier ton travail et t’indiquer la suite",
116+
"💡 Partager des conseils et des ressources",
117+
"🚀 Célébrer ta progression et la fin",
118+
"",
119+
"C'est parti, amuse-toi bien !",
120+
"",
121+
"Mona"
122+
].join('\n');
123+
await github.rest.issues.update({ owner, repo, issue_number: number, body });
106124
107125
- name: Enable next step workflow
108126
run: gh workflow enable "Step 1"
109127
env:
110-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128+
GH_TOKEN: ${{ github.token }}

.github/workflows/1-step.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Step 1
33
on:
44
# Se déclenche quand l'élève crée la branche de l’exercice
55
create:
6-
# Optionnel, si la branche est créée par un premier push
6+
# Si la branche est créée par un premier push
77
push:
88
branches: [ my-first-branch ]
99
workflow_dispatch:
@@ -12,21 +12,25 @@ permissions:
1212
contents: read
1313
actions: write
1414
issues: write
15-
pull-requests: write # si tu veux commenter sur les PR
16-
15+
pull-requests: write
16+
1717
env:
1818
STEP_2_FILE: ".github/steps/2-step.md"
1919

2020
jobs:
2121
find_exercise:
2222
name: Find Exercise Issue
23-
if: github.event_name == 'create' && github.event.ref_type == 'branch' && github.event.ref == 'my-first-branch'
23+
if: >
24+
(github.event_name == 'create' && github.event.ref_type == 'branch' && github.event.ref == 'my-first-branch')
25+
|| (github.event_name == 'push' && endsWith(github.ref, '/my-first-branch'))
2426
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
2527

2628
post_next_step_content:
2729
name: Post next step content
2830
needs: [find_exercise]
29-
if: github.event_name == 'create' && github.event.ref_type == 'branch' && github.event.ref == 'my-first-branch'
31+
if: >
32+
(github.event_name == 'create' && github.event.ref_type == 'branch' && github.event.ref == 'my-first-branch')
33+
|| (github.event_name == 'push' && endsWith(github.ref, '/my-first-branch'))
3034
runs-on: ubuntu-latest
3135
env:
3236
ISSUE_REPOSITORY: ${{ github.repository }}
@@ -61,7 +65,7 @@ jobs:
6165

6266
- name: Disable current workflow and enable next one
6367
run: |
64-
gh workflow disable "${{github.workflow}}"
68+
gh workflow disable "${{ github.workflow }}"
6569
gh workflow enable "Step 2"
6670
env:
67-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
GH_TOKEN: ${{ github.token }}

.github/workflows/2-step.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ permissions:
1212
contents: write
1313
actions: write
1414
issues: write
15-
pull-requests: write # si tu veux commenter sur les PR
16-
15+
pull-requests: write
16+
1717
env:
1818
STEP_3_FILE: ".github/steps/3-step.md"
1919

@@ -22,7 +22,7 @@ jobs:
2222
name: Find Exercise Issue
2323
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
2424

25-
# Optional "grading" job to check the practical work
25+
# "Grading" pour vérifier le travail
2626
check_step_work:
2727
name: Check step work
2828
runs-on: ubuntu-latest
@@ -52,8 +52,7 @@ jobs:
5252
file: .github/i18n/fr/checking-work.md
5353
edit-mode: replace
5454

55-
# START: Checks for this exercise
56-
55+
# START: Checks
5756
- name: Check if playground/README.md exists
5857
id: check-file-exists
5958
continue-on-error: true
@@ -84,7 +83,6 @@ jobs:
8483
passed: ${{ steps.check-file-exists.outcome == 'success' }}
8584
- description: "Chercher le mot 'Hello' dans playground/README.md"
8685
passed: ${{ steps.check-for-keyphrase.outcome == 'success' }}
87-
8886
# END: Checks
8987

9088
- name: Fail job if not all checks passed
@@ -93,7 +91,6 @@ jobs:
9391

9492
post_next_step_content:
9593
name: Post next step content
96-
# Gating, on ne passe à l'étape 3 que si les checks sont OK
9794
needs: [find_exercise, check_step_work]
9895
runs-on: ubuntu-latest
9996
env:
@@ -129,7 +126,7 @@ jobs:
129126

130127
- name: Disable current workflow and enable next one
131128
run: |
132-
gh workflow disable "${{github.workflow}}"
129+
gh workflow disable "${{ github.workflow }}"
133130
gh workflow enable "Step 3"
134131
env:
135-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
132+
GH_TOKEN: ${{ github.token }}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ permissions:
99
contents: write
1010
actions: write
1111
issues: write
12-
pull-requests: write # si tu veux commenter sur les PR
12+
pull-requests: write
1313

1414
env:
1515
REVIEW_FILE: ".github/steps/x-review.md"
@@ -19,7 +19,7 @@ jobs:
1919
name: Find Exercise Issue
2020
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
2121

22-
# Optional: when PR opens, post coaching (reuses step 3 content)
22+
# Quand la PR s'ouvre, poster un coaching
2323
on-opened:
2424
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
2525
runs-on: ubuntu-latest
@@ -59,7 +59,7 @@ jobs:
5959
file: ${{ env.REVIEW_FILE }}
6060

6161
- name: Disable current workflow
62-
run: gh workflow disable "${{github.workflow}}"
62+
run: gh workflow disable "${{ github.workflow }}"
6363
env:
6464
GH_TOKEN: ${{ github.token }}
6565

@@ -102,7 +102,7 @@ jobs:
102102
- name: Commit README.md
103103
uses: stefanzweifel/git-auto-commit-action@v5
104104
with:
105-
commit_message: "docs(readme), félicitations finales en français"
105+
commit_message: "docs(readme): félicitations finales en français"
106106
file_pattern: README.md
107107

108108
- name: Commentaire final en français
@@ -116,6 +116,6 @@ jobs:
116116
owner, repo, issue_number: Number(process.env.ISSUE_NUMBER),
117117
body: [
118118
`🎉 Félicitations @${context.actor} tu as terminé l’exercice **GitHub Basics**.`,
119-
`Le README a été mis à jour avec un message final en français, bravo.`
119+
`Le README a été mis à jour avec un message final en français.`
120120
].join('\n\n')
121121
});

0 commit comments

Comments
 (0)