Skip to content

Commit 4cada68

Browse files
committed
feat(scripts): auto-inject GitHub Pages URL
- Update deploy workflow to compute and export SITE_URL - Modify `generate-resume.js` to auto-fill website URL if missing - Enhance `resume.yaml.example` with optional website URL comment These changes ensure that the website URL is automatically populated with the GitHub Pages deployment URL.
1 parent 9509d38 commit 4cada68

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/deploy.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ jobs:
9292
9393
echo "✅ Template setup complete!"
9494
95-
- name: 🔧 Compute base path for deployment
95+
- name: 🔧 Compute base path and deployment URL
9696
id: compute-base-path
9797
run: |
9898
# Extract repository name from GITHUB_REPOSITORY (format: owner/repo)
@@ -103,21 +103,26 @@ jobs:
103103
if [ "$REPO_NAME" = "${REPO_OWNER}.github.io" ]; then
104104
# User/org site: use root path
105105
BASE_PATH="/"
106+
SITE_URL="https://${REPO_OWNER}.github.io"
106107
echo "📍 Detected user/org site: ${REPO_NAME}"
107108
else
108109
# Project site: use /repo-name/ path
109110
BASE_PATH="/${REPO_NAME}/"
111+
SITE_URL="https://${REPO_OWNER}.github.io/${REPO_NAME}"
110112
echo "📍 Detected project site: ${REPO_NAME}"
111113
fi
112114
113115
echo "🔗 Base path: ${BASE_PATH}"
116+
echo "🌐 Site URL: ${SITE_URL}"
114117
echo "BASE_PATH=${BASE_PATH}" >> $GITHUB_OUTPUT
118+
echo "SITE_URL=${SITE_URL}" >> $GITHUB_OUTPUT
115119
116120
- name: 🏗️ Build application
117121
# Note: npm run build now automatically generates resume files if resume.yaml exists
118122
run: npm run build
119123
env:
120124
VITE_BASE_PATH: ${{ steps.compute-base-path.outputs.BASE_PATH }}
125+
VITE_SITE_URL: ${{ steps.compute-base-path.outputs.SITE_URL }}
121126

122127

123128
- name: ⚙️ Configure GitHub Pages

resume.yaml.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ cv:
2323
location: "San Francisco, CA"
2424
email: "jane@example.com"
2525
phone: "tel:+1-555-0123"
26+
# 🌐 Optional: Will auto-fill with GitHub Pages URL if left empty
2627
website: "https://janedeveloper.dev"
2728
resume_url: "https://janedeveloper.dev/resume.pdf"
2829
social_networks:

scripts/generate-resume.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*
1515
* Environment variables:
1616
* NODE_ENV or RESUME_ENV - Set environment (development, production, ci)
17+
* VITE_SITE_URL - Auto-injected GitHub Pages URL (set by CI/CD workflow)
1718
* Example: NODE_ENV=production node scripts/generate-resume.js
1819
*/
1920

@@ -265,6 +266,15 @@ if (!existsSync(sourceYamlPath)) {
265266
const yamlContent = readFileSync(sourceYamlPath, 'utf8');
266267
const fullData = load(yamlContent, { sortKeys: false });
267268

269+
// Auto-inject website URL if missing (from GitHub Pages deployment URL)
270+
if (fullData.cv && (!fullData.cv.website || fullData.cv.website.trim() === '')) {
271+
const deploymentUrl = process.env.VITE_SITE_URL;
272+
if (deploymentUrl) {
273+
fullData.cv.website = deploymentUrl;
274+
console.log(`🌐 Auto-injecting website URL: ${deploymentUrl}`);
275+
}
276+
}
277+
268278
// Log original section order for debugging
269279
if (config.build.verbose && fullData.cv?.sections) {
270280
const originalSectionNames = Object.keys(fullData.cv.sections);

0 commit comments

Comments
 (0)