Skip to content

Commit 0020a25

Browse files
committed
ci(publish): split deployment into gh-pages-triggered workflow
- Add `.github/workflows/deploy-gh-pages.yaml` to deploy on pushes to `gh-pages`. - Remove inline `deploy-root` job from `publish.yaml`; publish now pushes to `gh-pages`. - Run `scripts/render_index_sitemap.py` after checking out `gh-pages` so sitemap reflects committed data. - Add step-summary messages indicating push and that deployment workflow will run. - Fixes environment-protection block by ensuring deployment originates from `gh-pages`. Signed-off-by: Ashley Childress <6563688+anchildress1@users.noreply.github.com>
1 parent 97bdd51 commit 0020a25

File tree

2 files changed

+96
-41
lines changed

2 files changed

+96
-41
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Deploy to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- gh-pages
7+
8+
permissions:
9+
contents: read
10+
pages: write
11+
id-token: write
12+
13+
concurrency:
14+
group: pages-deployment
15+
cancel-in-progress: false
16+
17+
jobs:
18+
deploy:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
environment:
22+
name: github-pages
23+
url: ${{ steps.deployment.outputs.page_url }}
24+
steps:
25+
- name: Checkout gh-pages branch
26+
uses: actions/checkout@v5
27+
with:
28+
ref: gh-pages
29+
30+
- name: Prepare deployment artifact
31+
run: |
32+
echo "## 📦 Preparing GitHub Pages Deployment" >> $GITHUB_STEP_SUMMARY
33+
echo "- 📍 Source Branch: gh-pages" >> $GITHUB_STEP_SUMMARY
34+
35+
mkdir -p _site
36+
37+
# Extract username for URL construction
38+
username=$(echo ${{ github.repository }} | cut -d'/' -f1)
39+
ROOT_HOME="https://$username.github.io/"
40+
41+
# Copy and substitute robots.txt from assets
42+
if [ -f assets/robots.txt ]; then
43+
cp assets/robots.txt _site/robots.txt
44+
sed -i "s|{home}|$ROOT_HOME|g" _site/robots.txt
45+
sed -i "s|{root_home}|$ROOT_HOME|g" _site/robots.txt
46+
echo " ✅ robots.txt" >> $GITHUB_STEP_SUMMARY
47+
else
48+
echo " ⚠️ assets/robots.txt not found" >> $GITHUB_STEP_SUMMARY
49+
fi
50+
51+
# Copy sitemap if it exists
52+
if [ -f sitemap.xml ]; then
53+
cp sitemap.xml _site/
54+
echo " ✅ sitemap.xml" >> $GITHUB_STEP_SUMMARY
55+
fi
56+
57+
# Copy llms.txt from assets
58+
if [ -f assets/llms.txt ]; then
59+
cp assets/llms.txt _site/llms.txt
60+
sed -i "s|{home}|$ROOT_HOME|g" _site/llms.txt
61+
sed -i "s|{root_home}|$ROOT_HOME|g" _site/llms.txt
62+
echo " ✅ llms.txt" >> $GITHUB_STEP_SUMMARY
63+
else
64+
echo " ⚠️ assets/llms.txt not found" >> $GITHUB_STEP_SUMMARY
65+
fi
66+
67+
# Copy Google verification file
68+
if [ -f google6b80426bb396f31f.html ]; then
69+
cp google6b80426bb396f31f.html _site/
70+
echo " ✅ google6b80426bb396f31f.html" >> $GITHUB_STEP_SUMMARY
71+
fi
72+
73+
echo "" >> $GITHUB_STEP_SUMMARY
74+
echo "✅ Deployment artifact prepared" >> $GITHUB_STEP_SUMMARY
75+
76+
- name: Upload Pages artifact
77+
uses: actions/upload-pages-artifact@v4
78+
with:
79+
path: _site
80+
81+
- name: Deploy to GitHub Pages
82+
id: deployment
83+
uses: actions/deploy-pages@v4
84+
85+
- name: Deployment summary
86+
if: success()
87+
run: |
88+
echo "## 🚀 Deployment Successful" >> $GITHUB_STEP_SUMMARY
89+
echo "- 🌐 Deployed to: ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY
90+
echo "- ⏱️ Completed at: $(date -u +"%Y-%m-%d %H:%M:%S UTC")" >> $GITHUB_STEP_SUMMARY

.github/workflows/publish.yaml

Lines changed: 6 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -131,52 +131,17 @@ jobs:
131131
cp -R "$TMPDIR/scripts" ./
132132
fi
133133
134+
# We are now on the gh-pages branch. Run render_index_sitemap.py to regenerate
135+
# index.html and sitemap.xml using the posts_data.json we just copied.
136+
# This ensures the sitemap and index reflect the latest posts.
134137
if [ -f "scripts/render_index_sitemap.py" ]; then
135138
python scripts/render_index_sitemap.py
136139
fi
137140
141+
# Commit and push changes to gh-pages branch
138142
git add -A
139143
git commit -m "chore: deploy dev.to mirror" || echo "No changes to commit"
140144
git push origin gh-pages
141145
142-
deploy-root:
143-
runs-on: ubuntu-latest
144-
needs: deploy-mirror-site
145-
timeout-minutes: 5
146-
permissions:
147-
contents: read
148-
pages: write
149-
id-token: write
150-
environment:
151-
name: github-pages
152-
url: ${{ steps.deployment.outputs.page_url }}
153-
steps:
154-
- name: Checkout gh-pages
155-
uses: actions/checkout@v5
156-
with:
157-
ref: gh-pages
158-
159-
- name: Prepare root site files
160-
run: |
161-
echo "## 📦 Deploying to Root Site" >> $GITHUB_STEP_SUMMARY
162-
163-
mkdir -p _site
164-
username=$(echo ${{ github.repository }} | cut -d'/' -f1)
165-
HOME="https://$username.github.io/"
166-
cp assets/robots.txt _site/robots.txt
167-
sed -i "s|{home}|$HOME|g" _site/robots.txt
168-
sed -i "s|{root_home}|$HOME|g" _site/robots.txt
169-
cp sitemap.xml _site/
170-
cp assets/llms.txt _site/llms.txt
171-
cp google6b80426bb396f31f.html _site/
172-
173-
echo "- ✅ Prepared 4 files for deployment" >> $GITHUB_STEP_SUMMARY
174-
175-
- name: Upload artifact
176-
uses: actions/upload-pages-artifact@v4
177-
with:
178-
path: _site
179-
180-
- name: Deploy to GitHub Pages
181-
id: deployment
182-
uses: actions/deploy-pages@v4
146+
echo "- ✅ Pushed to gh-pages branch" >> $GITHUB_STEP_SUMMARY
147+
echo "- 🚀 Deployment workflow will trigger automatically" >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)