Skip to content

Commit 8276a6f

Browse files
committed
uigkyfjdthrsef
1 parent e4557d8 commit 8276a6f

1 file changed

Lines changed: 81 additions & 6 deletions

File tree

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

Lines changed: 81 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,78 @@
1+
name: Step 3 # Last step of the exercise
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, closed]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
actions: write
11+
issues: write
12+
pull-requests: write
13+
14+
env:
15+
REVIEW_FILE: ".github/steps/x-review.md"
16+
17+
jobs:
18+
find_exercise:
19+
name: Find Exercise Issue
20+
uses: skills/exercise-toolkit/.github/workflows/find-exercise-issue.yml@v0.7.1
21+
22+
on-opened:
23+
if: github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
- name: Comment on the PR
28+
uses: GrantBirki/comment@v2.1.1
29+
with:
30+
repository: ${{ github.repository }}
31+
issue-number: ${{ github.event.pull_request.number }}
32+
file: .github/steps/3-step.md
33+
34+
post_review_content:
35+
name: Post review content
36+
needs: [find_exercise]
37+
runs-on: ubuntu-latest
38+
env:
39+
ISSUE_REPOSITORY: ${{ github.repository }}
40+
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
41+
42+
steps:
43+
- name: Checkout
44+
uses: actions/checkout@v4
45+
46+
- name: Create comment - step finished - final review next
47+
uses: GrantBirki/comment@v2.1.1
48+
with:
49+
repository: ${{ env.ISSUE_REPOSITORY }}
50+
issue-number: ${{ env.ISSUE_NUMBER }}
51+
file: .github/i18n/fr/lesson-review.md
52+
53+
- name: Create comment - add review content
54+
uses: GrantBirki/comment@v2.1.1
55+
with:
56+
repository: ${{ env.ISSUE_REPOSITORY }}
57+
issue-number: ${{ env.ISSUE_NUMBER }}
58+
file: ${{ env.REVIEW_FILE }}
59+
60+
- name: Disable current workflow
61+
run: gh workflow disable ".github/workflows/3-last-step.yml"
62+
env:
63+
GH_TOKEN: ${{ github.token }}
64+
continue-on-error: true
65+
66+
finish_exercise:
67+
name: Finish Exercise
68+
needs: [find_exercise, post_review_content]
69+
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
70+
uses: skills/exercise-toolkit/.github/workflows/finish-exercise.yml@v0.7.1
71+
with:
72+
issue-url: ${{ needs.find_exercise.outputs.issue-url }}
73+
exercise-title: "GitHub Basics"
74+
update-readme-with-congratulations: false
75+
176
finalize_fr:
277
name: Finalize FR
378
needs: [find_exercise, post_review_content, finish_exercise]
@@ -11,7 +86,7 @@
1186
persist-credentials: true
1287
fetch-depth: 0
1388

14-
- name: Mettre à jour README avec bloc FR et liens de partage
89+
- name: Update README with final FR block and share links
1590
uses: actions/github-script@v7
1691
with:
1792
script: |
@@ -20,13 +95,13 @@
2095
const {owner, repo} = context.repo;
2196
const login = context.actor;
2297
const repoUrl = `https://github.com/${owner}/${repo}`;
98+
2399
const text = `Je viens de terminer l’exercice "GitHub Basics" ! 🎉\n\n${repoUrl}\n\n#GitHubSkills #OpenSource #GitHubLearn`;
24100
const enc = encodeURIComponent(text);
25101
const shareX = `https://twitter.com/intent/tweet?text=${enc}`;
26102
const shareBsky = `https://bsky.app/intent/compose?text=${enc}`;
27103
const shareLinkedIn = `https://www.linkedin.com/feed/?shareActive=true&text=${enc}`;
28104
29-
// Tout le bloc HTML/Markdown encapsulé dans une string JS
30105
const block = `
31106
<div align="center">
32107

@@ -62,13 +137,13 @@
62137
</div>
63138

64139
---
65-
`;
140+
`.trim() + "\n";
66141
67142
const readmePath = path.join(process.env.GITHUB_WORKSPACE, 'README.md');
68143
const current = fs.existsSync(readmePath) ? fs.readFileSync(readmePath, 'utf8') : '';
69-
fs.writeFileSync(readmePath, `${block}\n${current}`, 'utf8');
144+
fs.writeFileSync(readmePath, `${block}${current}`, 'utf8');
70145

71-
- name: Commit et push du README final FR
146+
- name: Commit and push final README
72147
shell: bash
73148
env:
74149
GIT_AUTHOR_NAME: github-actions[bot]
@@ -87,7 +162,7 @@
87162
git pull --rebase origin main || true
88163
git push origin HEAD:main
89164
90-
- name: Remplacer le commentaire final EN par FR
165+
- name: Replace final EN comment with FR
91166
uses: actions/github-script@v7
92167
env:
93168
ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }}

0 commit comments

Comments
 (0)