Éviter les doublons pendant le rattrapage des étapes #82
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Step 0 # Démarrer l'exercice | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| actions: write | |
| issues: write | |
| env: | |
| STEP_1_FILE: ".github/steps/1-create-a-branch.md" | |
| TOOLKIT_REPOSITORY: "ENSTARobotics/exercise-toolkit-fr" | |
| TOOLKIT_REF: "19f8395fee473aca8af74039182a41cdda9ab0e3" | |
| jobs: | |
| start_exercise: | |
| if: | | |
| !github.event.repository.is_template | |
| name: Démarrer l'exercice | |
| uses: ENSTARobotics/exercise-toolkit-fr/.github/workflows/start-exercise.yml@19f8395fee473aca8af74039182a41cdda9ab0e3 | |
| with: | |
| exercise-title: "GitHub Basics" | |
| intro-message: "Tu vas apprendre les bases de GitHub en réalisant une petite modification guidée. Chaque notion sera expliquée juste avant sa première utilisation." | |
| manage-workflows: true | |
| toolkit-ref: "19f8395fee473aca8af74039182a41cdda9ab0e3" | |
| post_next_step_content: | |
| name: Afficher l'étape 1 | |
| runs-on: ubuntu-latest | |
| needs: [start_exercise] | |
| env: | |
| ISSUE_REPOSITORY: ${{ github.repository }} | |
| ISSUE_NUMBER: ${{ needs.start_exercise.outputs.issue-number }} | |
| steps: | |
| - name: Récupérer le dépôt | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 | |
| with: | |
| ref: main | |
| - name: Récupérer les templates français | |
| uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 | |
| with: | |
| repository: ${{ env.TOOLKIT_REPOSITORY }} | |
| path: exercise-toolkit-fr | |
| ref: ${{ env.TOOLKIT_REF }} | |
| - name: Publier l'étape 1 | |
| uses: GrantBirki/comment@608e41b19bc973020ec0e189ebfdae935d7fe0cc # v2.1.1 | |
| with: | |
| repository: ${{ env.ISSUE_REPOSITORY }} | |
| issue-number: ${{ env.ISSUE_NUMBER }} | |
| file: ${{ env.STEP_1_FILE }} | |
| - name: Indiquer que la progression est surveillée | |
| uses: GrantBirki/comment@608e41b19bc973020ec0e189ebfdae935d7fe0cc # v2.1.1 | |
| with: | |
| repository: ${{ env.ISSUE_REPOSITORY }} | |
| issue-number: ${{ env.ISSUE_NUMBER }} | |
| file: exercise-toolkit-fr/markdown-templates/step-feedback/watching-for-progress.md | |
| - name: Activer l'étape 1 et rattraper une branche déjà créée | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| current_state="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/0-start-exercise.yml" --jq '.state')" | |
| if [ "$current_state" = "active" ]; then | |
| gh api --method PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/0-start-exercise.yml/disable" | |
| fi | |
| next_state="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/1-create-a-branch.yml" --jq '.state')" | |
| if [ "$next_state" != "active" ]; then | |
| gh api --method PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/1-create-a-branch.yml/enable" | |
| fi | |
| # Laisse à GitHub quelques secondes pour enregistrer un événement déjà parti. | |
| echo "Attendre les événements déjà en vol..." | |
| sleep 2 | |
| if gh api "repos/${GITHUB_REPOSITORY}/branches/my-first-branch" >/dev/null 2>&1; then | |
| echo "La branche existe déjà : lancement immédiat de l'étape 1." | |
| gh workflow run 1-create-a-branch.yml --ref my-first-branch | |
| fi |