Skip to content

Step 1

Step 1 #1

name: Step 1 # Créer une branche
on:
push:
branches:
- "my-first-branch"
workflow_dispatch:
permissions:
contents: read
actions: write
issues: write
env:
STEP_2_FILE: ".github/steps/2-commit-a-file.md"
TOOLKIT_REPOSITORY: "ENSTARobotics/exercise-toolkit-fr"
TOOLKIT_REF: "19f8395fee473aca8af74039182a41cdda9ab0e3"
jobs:
find_exercise:
if: |
!github.event.repository.is_template &&
github.ref_name == 'my-first-branch'
name: Retrouver l'Issue de l'exercice
uses: ENSTARobotics/exercise-toolkit-fr/.github/workflows/find-exercise-issue.yml@19f8395fee473aca8af74039182a41cdda9ab0e3
post_next_step_content:
name: Afficher l'étape 2
needs: [find_exercise]
runs-on: ubuntu-latest
env:
ISSUE_REPOSITORY: ${{ github.repository }}
ISSUE_NUMBER: ${{ needs.find_exercise.outputs.issue-number }}
steps:
- name: Récupérer le contenu pédagogique depuis main
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: Confirmer l'étape terminé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/step-finished-prepare-next-step.md
vars: |
next_step_number: 2
- name: Publier l'étape 2
uses: GrantBirki/comment@608e41b19bc973020ec0e189ebfdae935d7fe0cc # v2.1.1
with:
repository: ${{ env.ISSUE_REPOSITORY }}
issue-number: ${{ env.ISSUE_NUMBER }}
file: ${{ env.STEP_2_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 2 et rattraper un commit déjà poussé
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
current_state="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/1-create-a-branch.yml" --jq '.state')"
if [ "$current_state" = "active" ]; then
gh api --method PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/1-create-a-branch.yml/disable"
fi
next_state="$(gh api "repos/${GITHUB_REPOSITORY}/actions/workflows/2-commit-a-file.yml" --jq '.state')"
if [ "$next_state" != "active" ]; then
gh api --method PUT "repos/${GITHUB_REPOSITORY}/actions/workflows/2-commit-a-file.yml/enable"
fi
if gh api "repos/${GITHUB_REPOSITORY}/contents/PROFILE.md?ref=my-first-branch" --jq '.content' > /tmp/profile.b64 2>/dev/null; then
tr -d '\n' < /tmp/profile.b64 | base64 -d > /tmp/PROFILE.md
if grep -qi 'Hello' /tmp/PROFILE.md; then
echo "PROFILE.md est déjà prêt : lancement immédiat de l'étape 2."
gh workflow run 2-commit-a-file.yml --ref my-first-branch
fi
fi