Merge Internal READMEs #23
This file contains hidden or 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: Merge Internal READMEs | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| merge-readmes: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1️⃣ Checkout repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| # 2️⃣ Merge all internal READMEs | |
| - name: Merge internal READMEs | |
| run: | | |
| MAIN_README="README.md" | |
| TMP_FILE="README.tmp.md" | |
| # Keep the first 20 lines of main README (header) | |
| head -n 20 "$MAIN_README" > "$TMP_FILE" | |
| # List of internal README paths | |
| INTERNAL_READMES=( | |
| "DesignPatterns/DesignPatterns.md" | |
| "Professional Trigs/Lightweight Log Llibrary/README.md" | |
| "Professional Trigs/SerialScope/README.md" | |
| ) | |
| for file in "${INTERNAL_READMES[@]}"; do | |
| if [ -f "$file" ]; then | |
| echo -e "\n\n---\n\n" >> "$TMP_FILE" | |
| echo "### Contents of $file" >> "$TMP_FILE" | |
| echo -e "\n" >> "$TMP_FILE" | |
| cat "$file" >> "$TMP_FILE" | |
| else | |
| echo "Warning: $file not found!" | |
| fi | |
| done | |
| # Force overwrite | |
| mv "$TMP_FILE" "$MAIN_README" | |
| # 3️⃣ Commit and push changes using PAT | |
| - name: Commit and push changes | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAT }} | |
| run: | | |
| git config --local user.name "Mohamadkhosravi" | |
| git config --local user.email "[email protected]" | |
| git add README.md | |
| git commit --allow-empty -m "Force merge internal READMEs into main README [skip ci]" | |
| git push https://[email protected]/Mohamadkhosravi/CodeForFun.git HEAD:main | |