Skip to content

Commit 06e56e0

Browse files
done
1 parent 068a55d commit 06e56e0

2 files changed

Lines changed: 108 additions & 0 deletions

File tree

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Update README File List
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- '**.php'
9+
10+
jobs:
11+
update-readme:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Generate File List
20+
id: file_list
21+
run: |
22+
echo "Generating file list..."
23+
# Find all .php files, sort them, and format as Markdown links
24+
# Format: - [Filename](URL)
25+
FILES=$(find . -maxdepth 1 -name "*.php" -type f | sort | sed 's|^\./||' | while read -r file; do echo "- [📄 $file](https://github.com/${{ github.repository }}/blob/main/$file)"; done)
26+
27+
# Export to environment variable (multiline safe)
28+
echo "FILES<<EOF" >> $GITHUB_ENV
29+
echo "$FILES" >> $GITHUB_ENV
30+
echo "EOF" >> $GITHUB_ENV
31+
32+
- name: Update README.md
33+
uses: actions/github-script@v7
34+
with:
35+
script: |
36+
const fs = require('fs');
37+
const readmePath = 'README.md';
38+
const startMarker = '<!-- FILES_START -->';
39+
const endMarker = '<!-- FILES_END -->';
40+
41+
if (fs.existsSync(readmePath)) {
42+
let content = fs.readFileSync(readmePath, 'utf8');
43+
const newContent = `${process.env.FILES}`;
44+
45+
const regex = new RegExp(`${startMarker}[\\s\\S]*?${endMarker}`);
46+
if (regex.test(content)) {
47+
const updatedContent = content.replace(regex, `${startMarker}\n${newContent}\n${endMarker}`);
48+
fs.writeFileSync(readmePath, updatedContent);
49+
console.log('README.md updated successfully.');
50+
} else {
51+
console.log('Markers not found in README.md');
52+
}
53+
} else {
54+
console.log('README.md not found');
55+
}
56+
57+
- name: Commit and Push changes
58+
run: |
59+
git config --global user.name "github-actions[bot]"
60+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
61+
git add README.md
62+
# Only commit if there are changes
63+
git diff --quiet && git diff --staged --quiet || (git commit -m "docs: auto-update file list in README" && git push)

README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# 🐘 PHP Programs Repository
2+
3+
![PHP](https://img.shields.io/badge/php-%23777BB4.svg?style=for-the-badge&logo=php&logoColor=white) ![GitHub Actions](https://img.shields.io/badge/github%20actions-%232671E5.svg?style=for-the-badge&logo=githubactions&logoColor=white) ![License](https://img.shields.io/github/license/ParasGupta-BCA/PHP-Programs?style=for-the-badge)
4+
5+
A curated collection of PHP programs and exercises for learning and reference. This repository features a modern web interface to browse and execute code directly in the browser.
6+
7+
## 🚀 Live Demo
8+
9+
Check out the interactive web version of this repository:
10+
### [👉 View Live PHP Portfolio](https://parasgupta-bca.github.io/PHP-Programs/)
11+
12+
---
13+
14+
## 📂 Course Content
15+
16+
Below is an automatically updated list of all PHP programs available in this repository.
17+
18+
<!-- FILES_START -->
19+
<!-- This section is automatically updated by GitHub Actions -->
20+
<!-- FILES_END -->
21+
22+
---
23+
24+
## 🛠 Features
25+
26+
- **Interactive File Viewer**: Browse code files with syntax highlighting.
27+
- **Live Execution**: Run PHP code directly in the browser via Piston API.
28+
- **Responsive Design**: Works on Desktop, Tablet, and Mobile.
29+
- **Auto-Sync**: This README stays up-to-date with repository contents automatically.
30+
31+
## 🤝 Contributing
32+
33+
Feel free to fork this repository and submit pull requests to add new interesting PHP examples!
34+
35+
1. Fork the Project
36+
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
37+
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
38+
4. Push to the Branch (`git push origin feature/AmazingFeature`)
39+
5. Open a Pull Request
40+
41+
---
42+
43+
<p align="center">
44+
Made with ❤️ by <a href="https://github.com/ParasGupta-BCA">Paras Gupta</a>
45+
</p>

0 commit comments

Comments
 (0)