Skip to content

Commit a6be0ca

Browse files
authored
fix: merge youtube-section-update into youtube-sync, cleanup stale workflows, update README (#254)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent f553b4c commit a6be0ca

4 files changed

Lines changed: 91 additions & 147 deletions

File tree

.github/workflows/social-media-post.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.github/workflows/youtube-section-update.yml

Lines changed: 0 additions & 127 deletions
This file was deleted.

.github/workflows/youtube-sync.yml

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,95 @@ jobs:
101101
print(' - [' + v['published'] + '] ' + v['title'])
102102
PY
103103
104-
- name: Commit et push si nouvelles videos
104+
- name: Injecter les videos dans music.html
105+
shell: bash
106+
run: |
107+
python <<'PY'
108+
import json
109+
import re
110+
import os
111+
112+
if not os.path.exists('assets/data/youtube-videos.json'):
113+
print('Fichier youtube-videos.json introuvable - abandon')
114+
exit(0)
115+
116+
with open('assets/data/youtube-videos.json', 'r', encoding='utf-8') as f:
117+
videos = json.load(f)
118+
119+
cards = ''
120+
for v in videos:
121+
if v.get('id') == 'placeholder':
122+
continue
123+
cards += (
124+
'<a href="' + v['url'] + '" target="_blank" rel="noopener noreferrer" class="yt-card">'
125+
'<div class="yt-thumb">'
126+
'<img src="' + v['thumbnail'] + '" alt="" loading="lazy" width="320" height="180">'
127+
'<span class="yt-play">&#9654;</span>'
128+
'</div>'
129+
'<p class="yt-title">' + v['title'] + '</p>'
130+
'<span class="yt-date">' + v['published'] + '</span>'
131+
'</a>'
132+
)
133+
134+
channel_link = ('<a href="https://www.youtube.com/@DavidKRKofficial"'
135+
' target="_blank" rel="noopener noreferrer"'
136+
' class="yt-channel-link">&#127909; <span id="youtube-btn-text">Voir toutes les vidéos</span></a>')
137+
138+
youtube_block = (
139+
'<!-- YOUTUBE-AUTO-START -->\n'
140+
' <h2 id="youtube-section-title">YouTube</h2>\n'
141+
' <div class="yt-grid">\n'
142+
' ' + channel_link + '\n'
143+
' <div class="yt-cards">' + cards + '</div>\n'
144+
' </div>\n'
145+
' <!-- YOUTUBE-AUTO-END -->'
146+
)
147+
148+
with open('music.html', 'r', encoding='utf-8') as f:
149+
content = f.read()
150+
151+
pattern = r'<!-- YOUTUBE-AUTO-START -->.*?<!-- YOUTUBE-AUTO-END -->'
152+
if re.search(pattern, content, re.DOTALL):
153+
content = re.sub(pattern, youtube_block, content, flags=re.DOTALL)
154+
else:
155+
content = content.replace('</main>', youtube_block + '\n </main>')
156+
157+
with open('music.html', 'w', encoding='utf-8') as f:
158+
f.write(content)
159+
print('music.html mis a jour !')
160+
161+
css_marker = '/* === YouTube Auto-Section === */'
162+
css_path = 'assets/css/style.css'
163+
if os.path.exists(css_path):
164+
with open(css_path, 'r', encoding='utf-8') as f:
165+
existing = f.read()
166+
if css_marker not in existing:
167+
css_content = (
168+
'\n' + css_marker + '\n'
169+
'.yt-grid { max-width: 960px; margin: 2rem auto; padding: 0 1rem; text-align: center; }\n'
170+
'.yt-channel-link { display: inline-block; margin-bottom: 1.5rem; color: #ff0000; font-weight: bold; font-size: 1.1rem; text-decoration: none; }\n'
171+
'.yt-channel-link:hover { opacity: 0.8; }\n'
172+
'.yt-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.2rem; }\n'
173+
'.yt-card { display: flex; flex-direction: column; background: rgba(0,0,0,0.45); border-radius: 10px; overflow: hidden; text-decoration: none; color: #fff; transition: transform 0.2s ease, box-shadow 0.2s ease; }\n'
174+
'.yt-card:hover { transform: translateY(-4px); box-shadow: 0 8px 24px rgba(255,0,0,0.2); }\n'
175+
'.yt-thumb { position: relative; }\n'
176+
'.yt-thumb img { width: 100%; height: 180px; object-fit: cover; display: block; }\n'
177+
'.yt-play { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%); font-size: 2.5rem; opacity: 0.85; pointer-events: none; }\n'
178+
'.yt-title { padding: 0.6rem 0.8rem 0.2rem; font-size: 0.9rem; font-weight: 600; text-align: left; }\n'
179+
'.yt-date { padding: 0 0.8rem 0.8rem; font-size: 0.75rem; color: #aaa; text-align: left; }\n'
180+
)
181+
with open(css_path, 'a', encoding='utf-8') as f:
182+
f.write(css_content)
183+
print('CSS YouTube ajoute a style.css')
184+
else:
185+
print('CSS YouTube deja present')
186+
PY
187+
188+
- name: Commit et push si changements
105189
run: |
106190
git config user.name "github-actions[bot]"
107191
git config user.email "github-actions[bot]@users.noreply.github.com"
108-
git add assets/data/youtube-videos.json
192+
git add assets/data/youtube-videos.json music.html assets/css/style.css
109193
if git diff --staged --quiet; then
110194
echo "Aucune nouvelle video detectee."
111195
else

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Uptime Monitor](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/uptime.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/uptime.yml)
77
[![Images](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/images.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/images.yml)
88
[![Music Social](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/music-social.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/music-social.yml)
9+
[![YouTube Sync](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/youtube-sync.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/youtube-sync.yml)
910
[![Maintenance](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/maintenance.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/maintenance.yml)
1011
![Website](https://img.shields.io/website?url=https%3A%2F%2Fwww.davidkrk.com&label=davidkrk.com)
1112
![GitHub last commit](https://img.shields.io/github/last-commit/DavidKRK/DavidKRK.github.io)
@@ -32,6 +33,9 @@ Official website of **David KRK**, DJ and music producer based in Saint-Jean-de-
3233
- **Performance Audits** : Lighthouse tests for speed, accessibility, SEO
3334
- **Automated Reports** : Performance badges and issue creation if scores drop
3435

36+
#### Daily (10 AM)
37+
- **YouTube Video Sync** : Fetches latest videos from YouTube API and updates music.html automatically
38+
3539
#### Weekly (Monday 10 AM)
3640
- **Dependency Updates** : Automatic npm package updates via Pull Request
3741
- **Link Checking** : Broken link detection and automated issue creation
@@ -74,6 +78,7 @@ This website is continuously monitored for:
7478
| **uptime.yml** | HTTP uptime monitoring + issue alerts | Every 30 min | [![Uptime](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/uptime.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/uptime.yml) |
7579
| **images.yml** | Auto image compression (JPEG/PNG/WebP) | On image push | [![Images](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/images.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/images.yml) |
7680
| **music-social.yml** | New music detection + social post template | On music.html change | [![Music Social](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/music-social.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/music-social.yml) |
81+
| **youtube-sync.yml** | YouTube video sync + music.html update | Daily 10 AM / On demand | [![YouTube Sync](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/youtube-sync.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/youtube-sync.yml) |
7782
| **maintenance.yml** | Lychee link check + backup + stale issues | Mon 8 AM / Sun 1 AM | [![Maintenance](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/maintenance.yml/badge.svg)](https://github.com/DavidKRK/DavidKRK.github.io/actions/workflows/maintenance.yml) |
7883

7984
### 🚀 Getting Started

0 commit comments

Comments
 (0)