Skip to content

Commit

Permalink
Mise à jour des workflows GitHub pour gérer les sous-modules et ajust…
Browse files Browse the repository at this point in the history
…ement de la génération de fichiers
  • Loading branch information
Mara-Li committed Dec 24, 2024
1 parent 10de415 commit 7e42df8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ permissions:
id-token: write

env:
FETCH_SUBMODULE: $submodule # change this to true if you use submodule for the docs
FETCH_SUBMODULE: false # change this to true if you use submodule for the docs

jobs:
deploy:
Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,22 @@ jobs:
|
auto_h1=''
comments=''
submodule=''
if [ "${{ github.event.inputs.auto_h1 }}" = "true" ]; then
auto_h1='--auto-h1'
fi
if [ "${{ github.event.inputs.comments }}" = "true" ]; then
comments='--comments'
fi
if [ "${{ github.event.inputs.submodule }}" = "true" ]; then
submodule='--submodule'
fi
echo "auto_h1=$auto_h1" >> $GITHUB_OUTPUT
echo "comments=$comments" >> $GITHUB_OUTPUT
echo "submodule=$submodule" >> $GITHUB_OUTPUT
echo "- auto_h1: $auto_h1" >> $GITHUB_STEP_SUMMARY
echo "- comments: $comments" >> $GITHUB_STEP_SUMMARY
echo "- submodule: $submodule" >> $GITHUB_STEP_SUMMARY
- name: Generate files
run: |
echo "📝 Generate files"
Expand All @@ -101,7 +107,7 @@ jobs:
echo "📝 Generate files" >> $GITHUB_STEP_SUMMARY
echo "---" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
python3 generate_template.py "${{github.event.inputs.site_name}}" "${{github.event.inputs.site_url}}" "${{github.event.inputs.site_description}}" "${{github.event.inputs.site_author}}" "${{github.event.inputs.language}}" ${{ steps.args.outputs.auto_h1 }} ${{ steps.args.outputs.comments }} >> $GITHUB_STEP_SUMMARY
uv run python generate_template.py "${{github.event.inputs.site_name}}" "${{github.event.inputs.site_url}}" "${{github.event.inputs.site_description}}" "${{github.event.inputs.site_author}}" "${{github.event.inputs.language}}" ${{ steps.args.outputs.auto_h1 }} ${{ steps.args.outputs.comments }} ${{steps.args.outputs.submodule}} >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
- name: Pull Request
id: cpr
Expand All @@ -124,12 +130,12 @@ jobs:
branch: generate
base: "main"
delete-branch: true
token: ${{ secrets.GH_TOKEN }}
token: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
- name: AutoMerging
id: automerge
if: ${{ inputs.AUTO_MERGE }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN || secrets.GITHUB_TOKEN }}
run: |
gh pr merge ${{ steps.cpr.outputs.pull-request-number }} --squash
echo "Pull Request merged"
Expand Down
9 changes: 3 additions & 6 deletions generate_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,11 @@ def main() -> None:
workflow_path = Path(".github/workflows/deploy.yml")
with workflow_path.open("r", encoding="UTF-8") as f:
workflow = f.read()
wf = Template(workflow)
subs = wf.substitute(
submodule=template.submodule
)
wf=workflow.replace("FETCH_SUBMODULE: false", "FETCH_SUBMODULE: true")
with workflow_path.open("w", encoding="UTF-8") as f:
f.write(subs)
f.write(wf)
print("Workflow template generated:")
print(subs)
print(wf)
print("Done!")

if __name__ == "__main__":
Expand Down

0 comments on commit 7e42df8

Please sign in to comment.