Files
hugo-blog/.gitea/workflows/deploy.yml
luochen570 d05adc2ffe
Some checks failed
Deploy Hugo Blog to k3s / build-and-deploy (push) Failing after 4m5s
ci: add Hugo blog CI/CD to k3s
- Enable Gitea Container Registry
- Dockerfile: nginx:alpine serving hugo public/
- Gitea Actions: build & push image + deploy to k3s
- k8s manifests: namespace hugo, deployment, service, ingress
- RBAC: allow runner to update deployments in hugo ns
- .gitignore: add public/ (CI builds it)
2026-05-31 03:09:14 +08:00

55 lines
1.2 KiB
YAML

name: Deploy Hugo Blog to k3s
on:
push:
branches: [main]
workflow_dispatch:
env:
REGISTRY: git.luochen570.cn
IMAGE: luochen570/hugo-blog
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Hugo
uses: peaceiris/actions-hugo@v3
with:
hugo-version: '0.161.1'
extended: true
- name: Hugo Build
run: hugo --minify
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Gitea Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: luochen570
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}
${{ env.REGISTRY }}/${{ env.IMAGE }}:latest
- name: Deploy to k3s
run: |
kubectl set image deployment/hugo-blog -n hugo \
nginx=${{ env.REGISTRY }}/${{ env.IMAGE }}:${{ github.sha }}