Skip to content

Commit

Permalink
Merge pull request #8 from Wambaborel/ci_cd
Browse files Browse the repository at this point in the history
Fix script syntax error in CI/CD workflow
  • Loading branch information
Wambaforestin authored Oct 28, 2024
2 parents d8883bd + a71954b commit c10fbd0
Showing 1 changed file with 24 additions and 48 deletions.
72 changes: 24 additions & 48 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,21 @@ jobs:
runs-on: ubuntu-latest

steps:
# Step 1: Checkout 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'
python-version: '3.12.7' # Set your desired Python version

# Step 3: Cache Dependencies
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('projects/**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
# Step 4: Install Dependencies for Each Subproject
- name: Install dependencies for each subproject
run: |
# Loop through each subproject directory
for dir in projects/*; do
if [ -d "$dir" ]; then
echo "Installing dependencies for $dir"
# Check if requirements.txt exists in the subproject
if [ -f "$dir/requirements.txt" ]; then
pip install -r "$dir/requirements.txt"
else
Expand All @@ -43,43 +33,29 @@ jobs:
fi
done
# Step 5: Generate README.md for New Projects
- name: Generate README.md for new projects
- name: Run README Generation
run: |
# Loop through each subproject directory to generate README files
for dir in projects/*; do
if [ ! -f "$dir/README.md" ]; then
echo "Generating README.md for $dir"
if [ -d "$dir" ]; then
project_name=$(basename "$dir")
cat <<- EOF > "$dir/README.md"
# $project_name
## Overview
This is the **$project_name** project, part of the Python project repository. This project includes functionality specific to the project's goal and is designed with modularity and reusability in mind.
## Setup
1. Clone the repository and navigate to this subproject:
```bash
git clone <repository-url>
cd projects/$project_name
```
2. Activate a virtual environment and install dependencies:
```bash
python3 -m venv venv
source venv/bin/activate # or venv\Scripts\activate on Windows
pip install -r requirements.txt
```
## Usage
1. Run the main script to see the project in action:
```bash
python main.py
```
## Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
Generated on $(date).
EOF
readme_file="$dir/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 "Generated README for $project_name"
fi
done

0 comments on commit c10fbd0

Please sign in to comment.