Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
109 changes: 109 additions & 0 deletions .github/workflows/ci-build-web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
name: Build and deploy web version
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize

jobs:
build_web:
name: Build web
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: start deployment
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: bobheadxi/deployments@v1
id: deployment
with:
ref: ${{ github.event.pull_request.head.sha }}
step: start
debug: true
env: preview-${{ github.event.pull_request.number }}

- name: Clone
uses: actions/checkout@v4

- name: Set deployment path
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
id: set-path
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "DEST_DIR=PR-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
echo "SITE_BASE=/PR-${{ github.event.pull_request.number }}/" >> $GITHUB_OUTPUT
else
echo "DEST_DIR=." >> $GITHUB_OUTPUT
echo "SITE_BASE=/" >> $GITHUB_OUTPUT
fi
echo ===============================
cat $GITHUB_OUTPUT

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '22'

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: |
pnpm install

- name: Build
run: pnpm run build
env:
SITE_BASE: ${{ steps.set-path.outputs.SITE_BASE }}

- name: Place hash file
run: echo "$GITHUB_SHA" > dist/site_hash.txt

- name: Install rsync (required for the next step)
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
run: |
sudo apt-get update && sudo apt-get install -y rsync

- name: Deploy PR preview or main site
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: dist
target-folder: ${{ steps.set-path.outputs.DEST_DIR }}
clean: false
single-commit: true

- name: Update deployment status
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: bobheadxi/deployments@v1
with:
step: finish
status: success
debug: true
env: ${{ steps.deployment.outputs.env }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
ref: ${{ github.event.pull_request.head.sha }}
env_url: https://fallout2-ce.github.io/PR-${{ github.event.pull_request.number }}/

- name: Check that site is deployed
run: |
URL="$SITE_ORIGIN""$SITE_BASE""site_hash.txt"
echo "Expecting $GITHUB_SHA from $URL"
for i in `seq 1 60`; do
got="$(curl -fsSL --max-time 10 "$URL" | tr -d '\r\n' || true)"
if [ "$got" = "$GITHUB_SHA" ]; then
echo "✅ Match on attempt $i: ${got}"
exit 0
fi
echo "Received $got, waiting"
sleep 5
done
exit 1

env:
SITE_ORIGIN: https://fallout2-ce.github.io
SITE_BASE: ${{ steps.set-path.outputs.SITE_BASE }}

55 changes: 55 additions & 0 deletions .github/workflows/ci-delete-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Cleanup PR Preview

on:
pull_request:
types:
- closed

jobs:
delete_pr_preview:
name: Delete PR preview from gh-pages
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: write
deployments: write
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}

- name: Remove PR preview folder
run: |
PR_FOLDER="PR-${{ github.event.pull_request.number }}"
echo "Removing preview folder: $PR_FOLDER"
git rm -r --ignore-unmatch "$PR_FOLDER" || true

- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $CURRENT_BRANCH"

if [ "$CURRENT_BRANCH" != "gh-pages" ]; then
echo "❌ Refusing to force-push to non-gh-pages branch: $CURRENT_BRANCH"
exit 1
fi

if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit --amend -m "🚮 Remove preview for closed PR #${{ github.event.pull_request.number }}"
git push --force
fi

- name: mark environment as deactivated
uses: bobheadxi/deployments@v1
with:
step: deactivate-env
env: preview-${{ github.event.pull_request.number }}
desc: Environment was pruned
debug: true
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
"typescript": "~5.8.3",
"typescript-eslint": "^8.39.1",
"vite": "^7.1.2"
}
},
"engines": {
"pnpm": ">=9.0.0"
},
"packageManager": "pnpm@9.12.0"
}
3 changes: 3 additions & 0 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
packages:
- .

onlyBuiltDependencies:
- '@tailwindcss/oxide'
- esbuild
4 changes: 2 additions & 2 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const Footer = () => {
<div className="w-full max-w-4xl justify-between p-4 items-center flex flex-col lg:flex-row gap-2 my-2 text-sm text-muted-foreground">
<div className="flex gap-6">
<a
href="https://discord.gg/"
href="https://discord.gg/qygBRUXuY6"
target="_blank"
rel="noopener noreferrer"
className="hover:scale-105"
>
<SiDiscord className="h-6 w-6" />
</a>
<a
href="https://t.me/"
href="https://t.me/+ssuTXrmgH4wzMGRi"
target="_blank"
rel="noopener noreferrer"
className="hover:scale-105"
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const Layout = () => {
createRoot(document.getElementById("root")!).render(
<StrictMode>
<ErrorBoundary>
<BrowserRouter>
<BrowserRouter basename={import.meta.env.BASE_URL}>
<Routes>
<Route element={<Layout />}>
<Route path="/" element={<App />} />
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import react from "@vitejs/plugin-react";
import path from "path";
import { defineConfig } from "vite";

const base = process.env.SITE_BASE || "/";

console.info(`Site base = ${base}`);

// https://vite.dev/config/
export default defineConfig({
base,
plugins: [react(), tailwindcss()],
resolve: {
alias: {
Expand Down