Skip to content

Commit

Permalink
Refactor CI/CD workflow to enhance README generation and dependency i…
Browse files Browse the repository at this point in the history
…nstallation steps
  • Loading branch information
Wambaforestin committed Nov 29, 2024
1 parent 5f7b893 commit 97bc51f
Showing 1 changed file with 69 additions and 65 deletions.
134 changes: 69 additions & 65 deletions .github/workflows/owner_ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,74 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3
# Step 1: Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3

# Step 2: Set up Python environment
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.7'

# Step 3: Install dependencies for each project
- name: Install dependencies for each project
run: |
for dir in */; do
# Skip non-project folders
if [[ "$dir" == ".github/" ]]; then
continue
fi
echo "Processing $dir"
if [ -f "$dir/requirements.txt" ]; then
echo "Installing dependencies for $dir"
pip install -r "$dir/requirements.txt"
else
echo "No requirements.txt found in $dir"
fi
done
# Step 4: Generate README files for each project
- name: Generate README files
run: |
for dir in */; do
# Skip non-project folders
if [[ "$dir" == ".github/" ]]; then
continue
fi
project_name=$(basename "$dir")
readme_file="$project_name/README.md"
# Create a README file with documentation
echo "# $project_name" > "$readme_file"
echo "" >> "$readme_file"
echo "## Description" >> "$readme_file"
echo "This is the README for the $project_name project." >> "$readme_file"
echo "" >> "$readme_file"
echo "## Installation" >> "$readme_file"
echo "To install the dependencies, run the following command:" >> "$readme_file"
echo "```bash" >> "$readme_file"
echo "pip install -r requirements.txt" >> "$readme_file"
echo "```" >> "$readme_file"
echo "" >> "$readme_file"
echo "## Usage" >> "$readme_file"
echo "Instructions for using the $project_name project go here." >> "$readme_file"
echo "" >> "$readme_file"
echo "---" >> "$readme_file"
echo "*📄 This README was automatically generated by the CI/CD workflow. 🤖*" >> "$readme_file"
echo "Generated README for $project_name"
done
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12.7'

- name: Install dependencies for each project
run: |
for dir in */; do
# Skip non-project folders
if [[ "$dir" == ".github/" ]]; then
continue
fi
echo "Processing $dir"
if [ -f "$dir/requirements.txt" ]; then
echo "Installing dependencies for $dir"
pip install -r "$dir/requirements.txt"
else
echo "No requirements.txt found in $dir"
fi
done
- name: Generate README files
run: |
for dir in */; do
# Skip non-project folders
if [[ "$dir" == ".github/" ]]; then
continue
fi
project_name=$(basename "$dir")
readme_file="$project_name/README.md"
# Create a README file with documentation
echo "# $project_name" > "$readme_file"
echo "" >> "$readme_file"
echo "## Description" >> "$readme_file"
echo "This is the README for the $project_name project." >> "$readme_file"
echo "" >> "$readme_file"
echo "## Installation" >> "$readme_file"
echo "To install the dependencies, run the following command:" >> "$readme_file"
echo "```bash" >> "$readme_file"
echo "pip install -r requirements.txt" >> "$readme_file"
echo "```" >> "$readme_file"
echo "" >> "$readme_file"
echo "## Usage" >> "$readme_file"
echo "Instructions for using the $project_name project go here." >> "$readme_file"
echo "" >> "$readme_file"
echo "---" >> "$readme_file"
echo "*📄 This README was automatically generated by the CI/CD workflow. 🤖*" >> "$readme_file"
echo "Generated README for $project_name"
done
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Update READMEs'
branch: main
repository: ${{ github.repository }}
commit_user_name: 'github-actions[bot]'
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
# Step 5: Commit and push changes
- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'Update READMEs'
branch: main
commit_user_name: 'github-actions[bot]'
commit_user_email: 'github-actions[bot]@users.noreply.github.com'

0 comments on commit 97bc51f

Please sign in to comment.