Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
- copilot/**
workflow_dispatch:

permissions:
contents: write # for JamesIves to push to gh-pages branch
pages: write # for Pages API to configure the deployment source

# Allow only one concurrent deployment, cancelling any in-progress run
concurrency:
group: pages
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
env:
BASE_PATH: /year-countdown

- name: Deploy to gh-pages branch
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: build
clean: true

- name: Configure Pages source to gh-pages branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
STATUS=$(curl -s -o response.json -w "%{http_code}" -X PUT \
-H "Authorization: Bearer $GH_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/pages" \
-d '{"build_type":"legacy","source":{"branch":"gh-pages","path":"/"}}')
if echo "$STATUS" | grep -qE '^2'; then
echo "Pages source configured to gh-pages branch (HTTP $STATUS)"
else
echo "Warning: Pages API returned HTTP $STATUS — manual configuration may be needed"
cat response.json || true
fi
42 changes: 42 additions & 0 deletions .github/workflows/preview-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Remove PR Preview

on:
pull_request:
types: [closed]

permissions:
contents: write

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Get sanitized branch name
id: branch
run: |
BRANCH="${{ github.head_ref }}"
SANITIZED=$(echo "$BRANCH" \
| sed 's/[^a-zA-Z0-9-]/-/g' \
| sed 's/-\+/-/g' \
| sed 's/^-//;s/-$//')
echo "name=$SANITIZED" >> "$GITHUB_OUTPUT"

- name: Checkout gh-pages branch
id: checkout
continue-on-error: true
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove preview directory
if: steps.checkout.outcome == 'success'
run: |
if [ -d "previews/${{ steps.branch.outputs.name }}" ]; then
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git rm -rf "previews/${{ steps.branch.outputs.name }}"
git commit -m "Remove preview for ${{ steps.branch.outputs.name }}"
git push
else
echo "Preview directory 'previews/${{ steps.branch.outputs.name }}' not found — nothing to clean up."
fi
82 changes: 82 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Deploy PR Preview

on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: write
pull-requests: write

# One preview deployment per PR at a time; cancel if a newer push arrives
concurrency:
group: preview-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get sanitized branch name
id: branch
run: |
BRANCH="${{ github.head_ref }}"
SANITIZED=$(echo "$BRANCH" \
| sed 's/[^a-zA-Z0-9-]/-/g' \
| sed 's/-\+/-/g' \
| sed 's/^-//;s/-$//')
echo "name=$SANITIZED" >> "$GITHUB_OUTPUT"

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
env:
BASE_PATH: /year-countdown/previews/${{ steps.branch.outputs.name }}

- name: Deploy preview
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build
target-folder: previews/${{ steps.branch.outputs.name }}

- name: Post preview URL comment
uses: actions/github-script@v7
with:
script: |
const previewUrl = `https://psdtools.github.io/year-countdown/previews/${{ steps.branch.outputs.name }}/`;
const marker = '<!-- preview-deployment-comment -->';
const body = `${marker}\n## 🚀 Preview Deployment\n\nYour preview is ready!\n\n**${previewUrl}**\n\n> This preview will be automatically removed when the PR is closed.`;

const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});

const existing = comments.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body,
});
}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,10 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# SvelteKit
.svelte-kit/
build/
.env
.env.*
!.env.example
Empty file added .nojekyll
Empty file.
89 changes: 0 additions & 89 deletions .replit

This file was deleted.

39 changes: 39 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/year-countdown/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link href="/year-countdown/_app/immutable/entry/start.qqnQlbdC.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/CoCjPWJw.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/C9l1F03v.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/BumdHySg.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/entry/app.BNOh3rkF.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/D1WECQzN.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/DhDXNBpt.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/BM3yWKy-.js" rel="modulepreload">
<link href="/year-countdown/_app/immutable/chunks/DGNFubKc.js" rel="modulepreload">

</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">
<script>
{
__sveltekit_1m5qj06 = {
base: "/year-countdown",
assets: "/year-countdown"
};

const element = document.currentScript.parentElement;

Promise.all([
import("/year-countdown/_app/immutable/entry/start.qqnQlbdC.js"),
import("/year-countdown/_app/immutable/entry/app.BNOh3rkF.js")
]).then(([kit, app]) => {
kit.start(app, element);
});
}
</script>
</div>
</body>
</html>
Loading
Loading