diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index a556d5d..0309a56 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -3,36 +3,49 @@ name: 🚀 MerphDev — Pipeline CI/CD on: push: branches: [main] + pull_request: branches: [main] + schedule: - - cron: '0 0 * * 1' # Every Monday at midnight — weekly check + - cron: '0 0 * * 1' jobs: - # ─── JOB 1: STRUCTURE VALIDATION ─── + +# ─── JOB 1 ─── validate: + name: ✅ Validate project structure runs-on: ubuntu-latest + steps: + - name: Checkout code uses: actions/checkout@v4 - name: Check required files exist run: | + echo "Checking project structure..." + required_files=( "README.md" + "learning-paths/cybersecurity.md" "learning-paths/ai-ml.md" "learning-paths/devops-cloud.md" "learning-paths/web-fullstack.md" "learning-paths/git-github.md" + "certifications/README.md" - "notes/README.md" + "notebooks/README.md" "models/README.md" + "docs/ROADMAP.md" ) + all_ok=true + for file in "${required_files[@]}"; do if [ ! -f "$file" ]; then echo "❌ MISSING: $file" @@ -41,11 +54,13 @@ jobs: echo "✅ OK: $file" fi done + if [ "$all_ok" = false ]; then - echo "❌ Validation failed — missing files" + echo "❌ Validation failed" exit 1 fi - echo "✅ All structure is valid" + + echo "✅ Structure OK" - name: Validate Markdown syntax uses: DavidAnson/markdownlint-cli2-action@v16 @@ -53,82 +68,118 @@ jobs: args: --config .markdownlint.json . continue-on-error: true - # ─── JOB 2: LINK CHECKING ─── + +# ─── JOB 2 ─── check-links: + name: 🔗 Check external links runs-on: ubuntu-latest + needs: validate + steps: + - name: Checkout code uses: actions/checkout@v4 - - name: Install link checking tool + - name: Install tool run: npm install -g markdown-link-check - - name: Check links in all Markdown files + - name: Check links run: | - echo "Checking external links..." - find . -name "*.md" -not -path "./node_modules/*" | while read file; do - echo "─── Checking: $file ───" - markdown-link-check "$file" --config .linkcheck.json || true - done - # ─── JOB 3: REPORT GENERATION ─── + echo "Checking links..." + + find . -name "*.md" \ + -not -path "./node_modules/*" \ + | while read file; do + + echo "Checking: $file" + + markdown-link-check "$file" \ + --config .linkcheck.json \ + || true + + done + + +# ─── JOB 3 ─── report: + name: 📊 Generate progress report runs-on: ubuntu-latest needs: validate + steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 with: python-version: '3.11' - name: Generate report run: | + python3 << 'EOF' - import os, json - from datetime import datetime - report = { - "generated_at": datetime.now().isoformat(), - "project": "MerphDev Learning and Certifications", - "statistics": {} - } - # Count Markdown files per directory - dirs_to_scan = ["learning-paths", "certifications", "notes", "models", "docs"] - for d in dirs_to_scan: - if os.path.exists(d): - md_files = [f for f in os.listdir(d) if f.endswith('.md')] - report["statistics"][d] = len(md_files) - with open("docs/latest-report.json", "w") as f: - json.dump(report, f, indent=2) - print("✅ Report generated:", json.dumps(report, indent=2)) - EOF - - - name: Upload report as artifact - uses: actions/upload-artifact@v4 + +import os, json +from datetime import datetime + +report = { + "generated_at": datetime.now().isoformat(), + "project": "MerphDev", + "statistics": {} +} + +dirs = [ +"learning-paths", +"certifications", +"notebooks", +"models", +"docs" +] + +for d in dirs: + if os.path.exists(d): + md_files = [ + f for f in os.listdir(d) + if f.endswith('.md') + ] + report["statistics"][d] = len(md_files) + +os.makedirs("docs", exist_ok=True) + +with open("docs/latest-report.json","w") as f: + json.dump(report,f,indent=2) + +print("Report generated") + +EOF + + - uses: actions/upload-artifact@v4 with: name: progress-report path: docs/latest-report.json - # ─── JOB 4: DEPLOYMENT ─── + +# ─── JOB 4 ─── deploy: + name: 🚀 Deploy to GitHub Pages runs-on: ubuntu-latest needs: [validate, report] + if: github.ref == 'refs/heads/main' + permissions: contents: write + steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 + - uses: actions/checkout@v4 + + - uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs - publish_branch: gh-pages - commit_message: "docs: deploy latest documentation [CI/CD]" + publish_branch: gh-pages