migrate from astro+netlify to tanstack start + self-hosted
Replace the Astro static site with a TanStack Start (Bun runtime) app and add Dockerfile + compose files so the site can be served from home-main-2 behind the home-reverse-proxy-1 Caddy instead of Netlify. CI workflow rewritten to build a container image and SSH-deploy to the home host.
This commit is contained in:
+69
-37
@@ -1,46 +1,78 @@
|
||||
name: Deploy to Netlify
|
||||
name: Build & Deploy unom website
|
||||
run-name: ${{ gitea.actor }} is deploying unom/website
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
types: [opened, synchronize]
|
||||
branches: [main]
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
build:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4.2.2
|
||||
|
||||
- name: Repository Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.bun/install/cache
|
||||
key: ${{ runner.os }}-${{ matrix.bun }}-bun-${{ hashFiles('**/bun.lockb') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-${{ matrix.bun }}-bun-
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v1
|
||||
with:
|
||||
bun-version: latest
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
- name: Set up Docker Buildx
|
||||
env:
|
||||
UNOM_PKGS_TOKEN: ${{ secrets.UNOM_PKGS_TOKEN }}
|
||||
BUILDER: builder-unom-website
|
||||
run: |
|
||||
cat > /tmp/buildkitd.toml <<'EOF'
|
||||
[registry."docker.io"]
|
||||
mirrors = ["192.168.1.52:5000"]
|
||||
[registry."192.168.1.52:5000"]
|
||||
http = true
|
||||
insecure = true
|
||||
EOF
|
||||
docker buildx rm "$BUILDER" 2>/dev/null || true
|
||||
docker buildx create --name "$BUILDER" --use --bootstrap \
|
||||
--driver docker-container \
|
||||
--config /tmp/buildkitd.toml
|
||||
|
||||
- name: Build
|
||||
run: bun run build
|
||||
|
||||
- name: Deploy to Netlify
|
||||
uses: nwtgck/actions-netlify@v2
|
||||
with:
|
||||
publish-dir: './dist'
|
||||
production-branch: main
|
||||
deploy-message: "Deploy from Gitea Actions"
|
||||
- name: Log in to Gitea registry
|
||||
env:
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
||||
timeout-minutes: 10
|
||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
||||
run: |
|
||||
printf '%s' "$REGISTRY_TOKEN" | docker login git.unom.io -u "$REGISTRY_USER" --password-stdin
|
||||
|
||||
- name: Build & push
|
||||
env:
|
||||
BUILDER: builder-unom-website
|
||||
IMAGE: git.unom.io/${{ gitea.repository }}
|
||||
SHA: ${{ gitea.sha }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--builder "$BUILDER" \
|
||||
--push \
|
||||
--file ./Dockerfile \
|
||||
--tag "$IMAGE:latest" \
|
||||
--tag "$IMAGE:$SHA" \
|
||||
--cache-from "type=registry,ref=$IMAGE:cache" \
|
||||
--cache-to "type=registry,ref=$IMAGE:cache,mode=min" \
|
||||
.
|
||||
|
||||
- name: Tear down builder
|
||||
if: always()
|
||||
env:
|
||||
BUILDER: builder-unom-website
|
||||
run: |
|
||||
docker buildx rm "$BUILDER" 2>/dev/null || true
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: build
|
||||
steps:
|
||||
- name: Pull and start web
|
||||
uses: appleboy/ssh-action@v1.2.5
|
||||
with:
|
||||
host: ${{ secrets.DEPLOY_HOST }}
|
||||
username: ${{ secrets.DEPLOY_USER }}
|
||||
port: ${{ secrets.DEPLOY_PORT }}
|
||||
key: ${{ secrets.DEPLOY_SSH_KEY }}
|
||||
script: |
|
||||
docker login git.unom.io -u ${{ secrets.REGISTRY_USER }} -p ${{ secrets.REGISTRY_TOKEN }}
|
||||
cd ~/unom-website
|
||||
git fetch origin main
|
||||
git reset --hard origin/main
|
||||
docker compose -f compose.production.yml pull web
|
||||
docker compose -f compose.production.yml up -d --no-build web
|
||||
|
||||
Reference in New Issue
Block a user