11name : Restore index.html
22
33on :
4+ push :
5+ paths :
6+ - ' .github/workflows/restore-index.yml'
47 workflow_dispatch :
58
69permissions :
@@ -18,21 +21,58 @@ jobs:
1821 run : |
1922 # Get the full index.html from commit 8ba7810 (before truncation)
2023 git checkout 8ba7810 -- index.html
21- # Add m3-interactions.js script tag
22- sed -i 's|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>\n <script src="assets/javascripts/m3-interactions.js"></script>|' index.html
24+ # Add m3-interactions.js script tag if not present
25+ if ! grep -q 'm3-interactions.js' index.html; then
26+ sed -i 's|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>\n <script src="assets/javascripts/m3-interactions.js"></script>|' index.html
27+ fi
2328 # Verify
24- echo "File size: $(wc -c < index.html)"
25- grep -c 'm3-flagship.css' index.html && echo 'CSS linked'
26- grep -c 'm3-interactions.js' index.html && echo 'JS linked'
29+ echo "File size: $(wc -c < index.html) bytes "
30+ grep -c 'm3-flagship.css' index.html && echo 'CSS: linked' || echo 'CSS: MISSING '
31+ grep -c 'm3-interactions.js' index.html && echo 'JS: linked' || echo 'JS: MISSING '
2732
28- - name : Commit and push
33+ - name : Commit and push restored file
2934 run : |
3035 git config user.name "github-actions[bot]"
3136 git config user.email "github-actions[bot]@users.noreply.github.com"
3237 git add index.html
33- git commit -m "fix: restore full index.html (92KB) with m3-interactions.js
38+ git diff --cached --quiet && echo 'No changes needed' || {
39+ git commit -m "fix: restore full index.html (92KB) with all enhancements
3440
35- Previous commit accidentally truncated index.html from 92KB to 13KB.
36- This restores the complete homepage from commit 8ba7810 and adds
37- the m3-interactions.js script tag."
38- git push
41+ Restored from commit 8ba7810 with m3-interactions.js script tag added.
42+ Previous commit accidentally truncated the file from 92KB to 13KB."
43+ git push
44+ }
45+
46+ - name : Self-cleanup - revert workflow to manual-only
47+ run : |
48+ # After restoration, update workflow to only trigger manually
49+ cat > .github/workflows/restore-index.yml << 'WORKFLOW'
50+ name: Restore index.html
51+ on:
52+ workflow_dispatch:
53+ permissions:
54+ contents: write
55+ jobs:
56+ restore:
57+ runs-on: ubuntu-latest
58+ steps:
59+ - uses: actions/checkout@v4
60+ with:
61+ fetch-depth: 0
62+ - name: Restore index.html
63+ run: |
64+ git checkout 8ba7810 -- index.html
65+ if ! grep -q 'm3-interactions.js' index.html; then
66+ sed -i 's|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>|<script src="assets/javascripts/bundle.79ae519e.min.js"></script>\n <script src="assets/javascripts/m3-interactions.js"></script>|' index.html
67+ fi
68+ echo "Size: $(wc -c < index.html)"
69+ - name: Commit
70+ run: |
71+ git config user.name "github-actions[bot]"
72+ git config user.email "github-actions[bot]@users.noreply.github.com"
73+ git add index.html
74+ git diff --cached --quiet || git commit -m "fix: restore index.html" && git push
75+ WORKFLOW
76+ git add .github/workflows/restore-index.yml
77+ git commit -m "ci: revert restore workflow to manual-only trigger" || true
78+ git push || true
0 commit comments