Skip to content

Commit c270879

Browse files
committed
fix: mismatched button/Link in mobile menu; ci: replace repo homepage update with PR description update
1 parent 6beda55 commit c270879

2 files changed

Lines changed: 50 additions & 8 deletions

File tree

.github/workflows/nextjs-static-gh-pages.yml

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,56 @@ jobs:
277277
console.log(`README updated with preview URL: ${previewUrl}`);
278278
}
279279
280-
- name: 🌐 Update GitHub repo homepage URL
281-
if: github.event_name == 'push' && steps.vars.outputs.is_main == 'true'
280+
- name: 📌 Update PR description with preview URL
281+
if: github.event_name == 'push'
282282
uses: actions/github-script@v7
283283
with:
284284
script: |
285+
const owner = context.repo.owner;
286+
const repo = context.repo.repo;
287+
const branch = '${{ steps.vars.outputs.branch }}';
285288
const previewUrl = '${{ steps.vars.outputs.preview_url }}';
286-
await github.rest.repos.update({
287-
owner: context.repo.owner,
288-
repo: context.repo.repo,
289-
homepage: previewUrl,
289+
const sha = context.sha.substring(0, 7);
290+
291+
// Find open PR for this branch
292+
const { data: prs } = await github.rest.pulls.list({
293+
owner, repo, head: `${owner}:${branch}`, state: 'open',
290294
});
291-
console.log(`Repository homepage updated to: ${previewUrl}`);
295+
296+
if (prs.length === 0) {
297+
console.log(`No open PR found for branch ${branch}, skipping.`);
298+
return;
299+
}
300+
301+
const pr = prs[0];
302+
const body = pr.body || '';
303+
304+
const marker = {
305+
start: '<!-- GH-PAGES-PREVIEW:START -->',
306+
end: '<!-- GH-PAGES-PREVIEW:END -->',
307+
};
308+
309+
const section = [
310+
marker.start,
311+
`---`,
312+
`🌐 **Preview:** [${previewUrl}](${previewUrl}) `,
313+
`_Deployed from \`${sha}\`_`,
314+
`---`,
315+
marker.end,
316+
].join('\n');
317+
318+
let updated;
319+
if (body.includes(marker.start)) {
320+
const re = new RegExp(`${marker.start}[\\s\\S]*?${marker.end}`);
321+
updated = body.replace(re, section);
322+
} else {
323+
// Prepend to top of PR description
324+
updated = section + '\n\n' + body;
325+
}
326+
327+
if (updated !== body) {
328+
await github.rest.pulls.update({
329+
owner, repo, pull_number: pr.number, body: updated,
330+
});
331+
console.log(`PR #${pr.number} description updated with preview URL: ${previewUrl}`);
332+
}

src/components/layout/header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ const StickyHeader: React.FC = () => {
242242
</Link>
243243
)
244244
})}
245-
<button
245+
<Link
246+
href="/invoice"
246247
className="text-white bg-[rgba(0,0,0,0.2)] border px-4 py-2 rounded hover:bg-[rgba(0,0,0,0.3)]"
247248
onClick={toggleMobileMenu}
248249
>

0 commit comments

Comments
 (0)