|
| 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 | + |
1 | 76 | finalize_fr: |
2 | 77 | name: Finalize FR |
3 | 78 | needs: [find_exercise, post_review_content, finish_exercise] |
|
11 | 86 | persist-credentials: true |
12 | 87 | fetch-depth: 0 |
13 | 88 |
|
14 | | - - name: Mettre à jour README avec bloc FR et liens de partage |
| 89 | + - name: Update README with final FR block and share links |
15 | 90 | uses: actions/github-script@v7 |
16 | 91 | with: |
17 | 92 | script: | |
|
20 | 95 | const {owner, repo} = context.repo; |
21 | 96 | const login = context.actor; |
22 | 97 | const repoUrl = `https://github.com/${owner}/${repo}`; |
| 98 | +
|
23 | 99 | const text = `Je viens de terminer l’exercice "GitHub Basics" ! 🎉\n\n${repoUrl}\n\n#GitHubSkills #OpenSource #GitHubLearn`; |
24 | 100 | const enc = encodeURIComponent(text); |
25 | 101 | const shareX = `https://twitter.com/intent/tweet?text=${enc}`; |
26 | 102 | const shareBsky = `https://bsky.app/intent/compose?text=${enc}`; |
27 | 103 | const shareLinkedIn = `https://www.linkedin.com/feed/?shareActive=true&text=${enc}`; |
28 | 104 |
|
29 | | - // Tout le bloc HTML/Markdown encapsulé dans une string JS |
30 | 105 | const block = ` |
31 | 106 | <div align="center"> |
32 | 107 |
|
|
62 | 137 | </div> |
63 | 138 |
|
64 | 139 | --- |
65 | | -`; |
| 140 | +`.trim() + "\n"; |
66 | 141 |
|
67 | 142 | const readmePath = path.join(process.env.GITHUB_WORKSPACE, 'README.md'); |
68 | 143 | const current = fs.existsSync(readmePath) ? fs.readFileSync(readmePath, 'utf8') : ''; |
69 | | - fs.writeFileSync(readmePath, `${block}\n${current}`, 'utf8'); |
| 144 | + fs.writeFileSync(readmePath, `${block}${current}`, 'utf8'); |
70 | 145 |
|
71 | | - - name: Commit et push du README final FR |
| 146 | + - name: Commit and push final README |
72 | 147 | shell: bash |
73 | 148 | env: |
74 | 149 | GIT_AUTHOR_NAME: github-actions[bot] |
|
87 | 162 | git pull --rebase origin main || true |
88 | 163 | git push origin HEAD:main |
89 | 164 |
|
90 | | - - name: Remplacer le commentaire final EN par FR |
| 165 | + - name: Replace final EN comment with FR |
91 | 166 | uses: actions/github-script@v7 |
92 | 167 | env: |
93 | 168 | ISSUE_NUMBER: ${{ env.ISSUE_NUMBER }} |
|
0 commit comments