Skip to content

Commit 8d68396

Browse files
committed
Refactor preview deployment workflow for improved clarity and functionality
1 parent 4513c48 commit 8d68396

1 file changed

Lines changed: 23 additions & 29 deletions

File tree

.github/workflows/preview-deploy.yml

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Build and Deploy Live Preview
1+
name: Build Preview for Testing
22

33
on:
44
pull_request:
55
branches:
6-
- master
6+
- main
77
types: [opened, synchronize, reopened, closed]
88
push:
99
branches:
@@ -13,20 +13,11 @@ on:
1313
permissions:
1414
contents: read
1515
pull-requests: write
16-
pages: write
17-
id-token: write
1816

1917
jobs:
2018
build-preview:
2119
runs-on: ubuntu-latest
2220
if: github.event.action != 'closed'
23-
environment:
24-
name: github-pages-preview
25-
url: https://devnomadic.github.io/preview/${{ steps.branch-info.outputs.branch-name }}/
26-
permissions:
27-
contents: read
28-
pages: write
29-
id-token: write
3021
steps:
3122
- name: Checkout
3223
uses: actions/checkout@v4
@@ -52,47 +43,50 @@ jobs:
5243
5344
- name: Build with Jekyll for preview
5445
run: |
55-
# Update baseurl for preview deployment
56-
sed -i 's|baseurl: ""|baseurl: "/preview/${{ steps.branch-info.outputs.branch-name }}"|' _config.yml
5746
bundle exec jekyll build --destination ./_site
5847
env:
5948
JEKYLL_ENV: production
6049

61-
- name: Setup Pages for preview
62-
id: pages-preview
63-
uses: actions/configure-pages@v4
64-
65-
- name: Create preview directory structure
66-
run: |
67-
mkdir -p preview-site/preview/${{ steps.branch-info.outputs.branch-name }}
68-
cp -r _site/* preview-site/preview/${{ steps.branch-info.outputs.branch-name }}/
69-
7050
- name: Upload preview artifact
7151
uses: actions/upload-artifact@v4
7252
with:
7353
name: preview-site-${{ steps.branch-info.outputs.branch-name }}
74-
path: preview-site/
54+
path: ./_site
7555
retention-days: 7
7656

77-
- name: Comment on PR with preview URL
57+
- name: Comment on PR with preview info
7858
if: github.event_name == 'pull_request'
7959
uses: actions/github-script@v7
8060
with:
8161
script: |
8262
const { owner, repo } = context.repo;
8363
const prNumber = context.issue.number;
84-
const previewUrl = `https://${owner}.github.io/${repo}/preview/pr-${prNumber}/`;
64+
const runId = context.runId;
65+
const branchName = "${{ steps.branch-info.outputs.branch-name }}";
8566
8667
github.rest.issues.createComment({
8768
owner,
8869
repo,
8970
issue_number: prNumber,
90-
body: `🚀 **Live Preview Ready!**
71+
body: `🚀 **Preview Build Complete!**
72+
73+
Your preview has been built successfully and is ready for testing.
74+
75+
**Download & Test Locally:**
76+
1. Go to [Actions Run #${runId}](https://github.com/${owner}/${repo}/actions/runs/${runId})
77+
2. Download the \`preview-site-${branchName}\` artifact
78+
3. Extract and serve: \`cd extracted-folder && python3 -m http.server 8000\`
79+
4. Open http://localhost:8000 in your browser
9180
92-
Your preview is now live at: **${previewUrl}**
81+
💡 **Quick Test Command:**
82+
\`\`\`bash
83+
# After downloading and extracting:
84+
python3 -m http.server 8000
85+
# Then open: http://localhost:8000
86+
\`\`\`
9387
94-
📝 This preview will be updated automatically when you push new commits to this PR.
95-
🗑️ The preview will be cleaned up when the PR is merged or closed.`
88+
This preview updates automatically with each commit to this PR.`
89+
});
9690
9791
cleanup-preview:
9892
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)