added github action for auto deploy

This commit is contained in:
ClovertaTheTrilobita 2026-03-25 17:34:38 +02:00
parent 5da8e71344
commit e272c34c46
2 changed files with 73 additions and 1 deletions

65
.github/workflows/deploy-blog.yml vendored Normal file
View file

@ -0,0 +1,65 @@
name: Deploy Astro Blog
on:
push:
branches:
- main
paths:
- 'src/blog/**'
- 'src/friends/**'
- 'package.json'
- 'package-lock.json'
- 'astro.config.mjs'
- 'astro.config.ts'
- 'src/content/**'
- 'public/**'
- '.github/workflows/deploy-blog.yml'
workflow_dispatch:
concurrency:
group: deploy-blog
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
DEPLOY_HOST: ${{ vars.DEPLOY_HOST }}
DEPLOY_PORT: ${{ vars.DEPLOY_PORT }}
DEPLOY_PATH: ${{ vars.DEPLOY_PATH }}
DEPLOY_USER: ${{ vars.DEPLOY_USER }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build Astro site
run: npm run build
- name: Install rsync and ssh client
run: sudo apt-get update && sudo apt-get install -y rsync openssh-client
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo "${{ secrets.DEPLOY_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
chmod 644 ~/.ssh/known_hosts
- name: Deploy to server
run: |
rsync -avz --delete \
-e "ssh -p ${DEPLOY_PORT}" \
dist/ \
${DEPLOY_USER}@${DEPLOY_HOST}:${DEPLOY_PATH}/

View file

@ -13,12 +13,19 @@ const t = getTranslations(lang);
</div>
<nav class="header-nav">
<h1>{t.banner.title}</h1>
<h1>
<a href="/" data-astro-reload>{t.banner.title}</a>
</h1>
<Navigation />
</nav>
</header>
<style>
.header-nav h1 a {
color: inherit;
text-decoration: none;
}
.site-header {
position: relative;
padding-top: 0.5rem;