Skip to content

Commit 2396a1c

Browse files
authored
Update pages.yml
1 parent 6da6d00 commit 2396a1c

1 file changed

Lines changed: 34 additions & 66 deletions

File tree

.github/workflows/pages.yml

Lines changed: 34 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Deploy to GitHub Pages
1+
name: Deploy to GitHub Pages (force-write repo URL with debug)
22

33
on:
44
push:
@@ -28,57 +28,24 @@ jobs:
2828
sudo apt-get update
2929
sudo apt-get install -y pandoc jq
3030
31-
- id: ensure_license
32-
name: Ensure MIT License exists (and mark if created)
33-
run: |
34-
if [ ! -f LICENSE ]; then
35-
YEAR=$(date +%Y)
36-
printf '%s\n' "MIT License" "" "Copyright (c) $YEAR Steph Buongiorno" "" "Permission is hereby granted, free of charge, to any person obtaining a copy" "of this software and associated documentation files (the \"Software\"), to deal" "in the Software without restriction, including without limitation the rights" "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell" "copies of the Software, and to permit persons to whom the Software is" "furnished to do so, subject to the following conditions:" "" "The above copyright notice and this permission notice shall be included in all" "copies or substantial portions of the Software." "" "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR" "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY," "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE" "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER" "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM," "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE" "SOFTWARE." > LICENSE
37-
echo "MIT License generated."
38-
echo "created=true" >> "$GITHUB_OUTPUT"
39-
else
40-
echo "LICENSE file already exists — skipping generation."
41-
echo "created=false" >> "$GITHUB_OUTPUT"
42-
fi
43-
44-
- name: Commit LICENSE to repo (first time only)
45-
if: steps.ensure_license.outputs.created == 'true'
46-
env:
47-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48-
run: |
49-
git config user.name "github-actions[bot]"
50-
git config user.email "github-actions[bot]@users.noreply.github.com"
51-
git add LICENSE
52-
git commit -m "Add MIT LICENSE (auto-generated)"
53-
git push
54-
5531
- id: build_page
56-
name: Build index.html at root (prefer existing; fallback to README) with highlighted code
32+
name: Build index.html (keep existing, or README -> HTML)
5733
env:
5834
REPO_HTML_TITLE: ${{ github.repository }}
5935
run: |
60-
set -e
61-
GENERATED=0
62-
36+
set -euo pipefail
6337
if [ -f index.html ]; then
6438
echo "Keeping existing index.html (not regenerating)."
6539
elif [ -f README.md ]; then
66-
echo "Generating index.html from README.md with syntax highlighting..."
67-
pandoc README.md -f markdown -t html -s \
68-
--highlight-style=tango \
69-
-o index.html \
70-
--metadata title="$REPO_HTML_TITLE"
71-
GENERATED=1
40+
pandoc README.md -f markdown -t html -s --highlight-style=tango -o index.html --metadata title="$REPO_HTML_TITLE"
7241
else
73-
echo "No index.html or README.md found; writing minimal page."
7442
printf '%s\n' '<!doctype html><html><head><meta charset="utf-8"><title>Site</title></head><body>' '<h1>Site</h1>' '<p>No README.md found. Add one and push to regenerate this page.</p>' '</body></html>' > index.html
75-
GENERATED=1
7643
fi
7744
78-
# Inject CSS without sed (avoid escaping issues)
79-
CSS_BLOCK='<style>body{font-family:Arial,Helvetica,sans-serif} h1,h2,h3,h4,h5,h6{font-family:Arial,Helvetica,sans-serif} pre code{display:block;padding:.75em;background:#f6f8fa;border-radius:6px;font-size:90%;overflow:auto} code{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,\"Liberation Mono\",\"Courier New\",monospace}</style>'
45+
# Minimal CSS injection
46+
CSS_BLOCK='<style>body{font-family:Arial,Helvetica,sans-serif} pre code{display:block;padding:.75em;background:#f6f8fa;border-radius:6px;font-size:90%;overflow:auto}</style>'
8047
if grep -qi '</head>' index.html; then
81-
awk -v css="$CSS_BLOCK" 'BEGIN{IGNORECASE=1} { if (!done && match(tolower($0), /<\/head>/)) { sub(/<\/head>/, css"</head>"); done=1 } print }' index.html > index.html.tmp
48+
awk -v css="$CSS_BLOCK" 'BEGIN{IGNORECASE=1} { if (!done && match(tolower($0), /</head>/)) { sub(/</head>/, css"</head>"); done=1 } print }' index.html > index.html.tmp
8249
mv index.html.tmp index.html
8350
else
8451
TMP=$(mktemp)
@@ -88,34 +55,29 @@ jobs:
8855
mv "$TMP" index.html
8956
fi
9057
91-
echo "generated=$GENERATED" >> "$GITHUB_OUTPUT"
92-
93-
- name: Append License, Suggested Citation, BibTeX, and repo metadata
94-
if: steps.build_page.outputs.generated == '1'
58+
- name: Force-write License/Citation/BibTeX/Repository with URL + DEBUG
9559
env:
9660
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9761
REPO: ${{ github.repository }}
98-
OWNER: ${{ github.repository_owner }}
9962
shell: bash
10063
run: |
10164
set -Eeuo pipefail
102-
10365
REPO_NAME="${REPO#*/}"
10466
REPO_URL="https://github.com/$REPO"
10567
LAST_UPDATE=$(git log -1 --format=%cI || date -u +%Y-%m-%dT%H:%M:%SZ)
10668
YEAR=$(date -u -d "$LAST_UPDATE" +%Y 2>/dev/null || date -u +%Y)
10769
108-
logins=$(curl -s -H "Authorization: Bearer $GH_TOKEN" \
109-
"https://api.github.com/repos/$REPO/contributors?per_page=100&anon=false" \
110-
| jq -r '.[] | select((.type // "") != "Bot") | select(.login != "ghost") | .login' | sort -fu)
70+
echo "DEBUG: REPO=$REPO"
71+
echo "DEBUG: REPO_URL=$REPO_URL"
72+
echo "DEBUG: LAST_UPDATE=$LAST_UPDATE"
73+
74+
logins=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/repos/$REPO/contributors?per_page=100&anon=false" | jq -r '.[] | select((.type // "") != "Bot") | select(.login != "ghost") | .login' | sort -fu)
11175
11276
names=""
11377
for u in $logins; do
11478
name=$(curl -s -H "Authorization: Bearer $GH_TOKEN" "https://api.github.com/users/$u" | jq -r '.name // empty')
11579
[ -z "$name" ] && name="$u"
116-
if [ "$name" != "Steph Buongiorno" ] && [ "$u" != "stephbuon" ]; then
117-
names="$names\n$name"
118-
fi
80+
names="$names\n$name"
11981
done
12082
names_sorted=$(printf "%b" "$names" | awk 'NF' | sort -fu)
12183
@@ -138,24 +100,31 @@ jobs:
138100
note = {Last updated: $LAST_UPDATE}
139101
}"
140102
141-
# Append blocks using a here-doc so variables are expanded by bash
103+
# Remove any previous block entirely and append a fresh one
104+
awk 'BEGIN{p=1} /<!-- BEGIN-REPO-META -->/{p=0} /<!-- END-REPO-META -->/{next} p{print}' index.html > index.clean.html || true
105+
mv index.clean.html index.html || true
106+
142107
cat >> index.html <<HTMLBLOCK
108+
<!-- BEGIN-REPO-META -->
109+
<hr>
110+
<h2>License</h2>
111+
<p>This project is licensed under the <a href="LICENSE">MIT License</a>.</p>
143112
144-
<hr>
145-
<h2>License</h2>
146-
<p>This project is licensed under the <a href="LICENSE">MIT License</a>.</p>
113+
<h2>Suggested Citation</h2>
114+
<p>$citation_written</p>
147115
148-
<h2>Suggested Citation</h2>
149-
<p>$citation_written</p>
116+
<h3>BibTeX</h3>
117+
<pre><code>$bibtex</code></pre>
150118
151-
<h3>BibTeX</h3>
152-
<pre><code>$bibtex</code></pre>
119+
<h3>Repository</h3>
120+
<p><em>$REPO_NAME</em><br>
121+
<a href="$REPO_URL">$REPO_URL</a><br>
122+
<strong>Last updated:</strong> $LAST_UPDATE</p>
123+
<!-- END-REPO-META -->
124+
HTMLBLOCK
153125
154-
<h3>Repository</h3>
155-
<p><em>$REPO_NAME</em><br>
156-
<a href="$REPO_URL">$REPO_URL</a><br>
157-
<strong>Last updated:</strong> $LAST_UPDATE</p>
158-
HTMLBLOCK
126+
echo "---------- FINAL LINES OF index.html ----------"
127+
tail -n 60 index.html
159128
160129
- name: Upload site artifact
161130
uses: actions/upload-pages-artifact@v3
@@ -171,4 +140,3 @@ HTMLBLOCK
171140
steps:
172141
- id: deployment
173142
uses: actions/deploy-pages@v4
174-

0 commit comments

Comments
 (0)