Delete lectures/lecture3-prompting-for-programmers.html #1
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: Update README with New Lectures | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'lectures/**/*.html' | |
| - '.pdf-generation-log' # Trigger when PDFs are generated | |
| - '.video-generation-log' # Trigger when videos are generated | |
| workflow_dispatch: # Allow manual triggering | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-readme: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Update README with lecture links | |
| run: | | |
| # Create a Node.js script to update the README.md file | |
| cat > update-readme.js << 'EOF' | |
| const fs = require('fs'); | |
| const path = require('path'); | |
| function updateReadme() { | |
| console.log('Starting README update...'); | |
| const readmePath = 'README.md'; | |
| if (!fs.existsSync(readmePath)) { | |
| throw new Error('README.md not found'); | |
| } | |
| let readmeContent = fs.readFileSync(readmePath, 'utf8'); | |
| const lecturesDir = 'lectures'; | |
| if (!fs.existsSync(lecturesDir)) { | |
| throw new Error('Lectures directory does not exist: ' + lecturesDir); | |
| } | |
| const lectures = fs.readdirSync(lecturesDir, { withFileTypes: true }) | |
| .filter(dirent => dirent.isFile() && dirent.name.endsWith('.html')) | |
| .map(dirent => dirent.name) | |
| .sort(); | |
| console.log('Found lectures: ' + lectures.join(', ')); | |
| const lectureEntries = []; | |
| for (const lectureFile of lectures) { | |
| const lectureName = path.basename(lectureFile, '.html'); | |
| const match = lectureName.match(/^lecture(\d+)-(.+)$/); | |
| if (!match) { | |
| console.log('Skipping ' + lectureName + ' - does not match expected pattern'); | |
| continue; | |
| } | |
| const lectureNumber = parseInt(match[1]); | |
| const titleSlug = match[2]; | |
| const displayTitle = titleSlug | |
| .split('-') | |
| .map(word => word.charAt(0).toUpperCase() + word.slice(1)) | |
| .join(' '); | |
| const lectureUrl = 'https://danielcregg.github.io/AIAP-lecture-slides/lectures/' + lectureName + '.html'; | |
| const pdfUrl = 'https://github.com/danielcregg/AIAP-lecture-slides/raw/main/pdfs/' + lectureName + '.pdf'; | |
| const videoUrl = 'https://danielcregg.github.io/AIAP-lecture-slides/videos/' + lectureName + '.mp4'; | |
| // Check if PDF exists | |
| const pdfPath = 'pdfs/' + lectureName + '.pdf'; | |
| const pdfExists = fs.existsSync(pdfPath); | |
| // Check if video exists | |
| const videoPath = 'videos/' + lectureName + '.mp4'; | |
| const videoExists = fs.existsSync(videoPath); | |
| let entry = lectureNumber + '. **[' + displayTitle + '](' + lectureUrl + ')** ✅ Available'; | |
| if (pdfExists) { | |
| entry += ' | [📄 PDF](' + pdfUrl + ')'; | |
| } | |
| if (videoExists) { | |
| entry += ' | [🎥 Video](' + videoUrl + ')'; | |
| } | |
| lectureEntries.push({ | |
| number: lectureNumber, | |
| entry: entry | |
| }); | |
| } | |
| lectureEntries.sort((a, b) => a.number - b.number); | |
| const moduleStructureStart = readmeContent.indexOf('## 📚 Module Structure'); | |
| if (moduleStructureStart === -1) { | |
| throw new Error('Could not find Module Structure section in README'); | |
| } | |
| const nextSectionMatch = readmeContent.substring(moduleStructureStart + 1).match(/\n## /); | |
| let moduleStructureEnd; | |
| if (nextSectionMatch) { | |
| moduleStructureEnd = moduleStructureStart + 1 + nextSectionMatch.index; | |
| } else { | |
| moduleStructureEnd = readmeContent.length; | |
| } | |
| let introText = '## 📚 Module Structure\n\nThis module consists of a module introduction plus 8 main lectures:\n\n'; | |
| let newModuleStructure = introText; | |
| for (const lectureEntry of lectureEntries) { | |
| newModuleStructure += lectureEntry.entry + '\n'; | |
| } | |
| const maxLectures = 9; | |
| const remainingLectures = [ | |
| 'Code Review and Quality Assurance', | |
| 'Testing and Debugging with AI', | |
| 'Documentation and Communication', | |
| 'AI in Software Architecture', | |
| 'Ethics and Limitations', | |
| 'Future of AI-Assisted Programming', | |
| 'Lecture 8', | |
| 'Lecture 9' | |
| ]; | |
| for (let i = lectureEntries.length; i < maxLectures; i++) { | |
| const lectureNum = i + 1; | |
| const title = remainingLectures[i - 1] || 'Lecture ' + lectureNum; | |
| newModuleStructure += lectureNum + '. **' + title + '** 🚧 Coming Soon\n'; | |
| } | |
| const beforeSection = readmeContent.substring(0, moduleStructureStart); | |
| const afterSection = readmeContent.substring(moduleStructureEnd); | |
| const updatedReadme = beforeSection + newModuleStructure + '\n' + afterSection; | |
| fs.writeFileSync(readmePath, updatedReadme); | |
| console.log('README.md updated successfully!'); | |
| console.log('Updated lecture entries:'); | |
| lectureEntries.forEach(entry => console.log(' ' + entry.entry)); | |
| } | |
| try { | |
| updateReadme(); | |
| } catch (error) { | |
| console.error('Error updating README:', error); | |
| process.exit(1); | |
| } | |
| EOF | |
| - name: Run README update script | |
| run: node update-readme.js | |
| - name: Clean up trigger files | |
| run: | | |
| if [ -f .pdf-generation-log ]; then | |
| rm .pdf-generation-log | |
| echo "Cleaned up PDF generation trigger file" | |
| fi | |
| if [ -f .video-generation-log ]; then | |
| rm .video-generation-log | |
| echo "Cleaned up video generation trigger file" | |
| fi | |
| - name: Commit README changes | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add README.md | |
| # Also add the removal of the trigger files if they exist | |
| if [ -f .pdf-generation-log ]; then | |
| git add .pdf-generation-log | |
| fi | |
| if [ -f .video-generation-log ]; then | |
| git add .video-generation-log | |
| fi | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit to README.md" | |
| else | |
| git commit -m "Auto-update README with new lectures [skip ci]" || exit 0 | |
| git push | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |