Merge pull request #16 from Wambaborel/ci_cd #17
This file contains 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 of the workflow | |
name: CI/CD Workflow | |
# Trigger the workflow on push to the main branch | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
# Run the job on the latest Ubuntu runner | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Python | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12.7' | |
# Step 3: Install dependencies for each project in the root directory | |
- name: Install dependencies for each project | |
run: | | |
for dir in */; do | |
# Skip non-project folders (e.g., .github/) | |
if [[ "$dir" == ".github/" ]]; then | |
continue | |
fi | |
echo "Processing $dir" | |
# Check if a requirements.txt file exists in the project directory | |
if [ -f "$dir/requirements.txt" ]; then | |
echo "Installing dependencies for $dir" | |
# Install the dependencies listed in the requirements.txt file | |
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 (e.g., .github/) | |
if [[ "$dir" == ".github/" ]]; then | |
continue | |
fi | |
# Get the project name from the directory name | |
project_name=$(basename "$dir") | |
# Construct the full path for the README file | |
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 | |
# Step 5: Commit and push the changes back to the main branch | |
- name: Commit and push changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: 'Update READMEs' | |
branch: main |