54 lines
1.3 KiB
YAML
54 lines
1.3 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
|
|
|
|
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: Build and Push Docker Image
|
|
env:
|
|
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
|
|
run: |
|
|
# Find the Docker daemon (dind is on the gateway)
|
|
DOCKER_HOST_IP=$(ip route | grep default | awk '{print $3}')
|
|
export DOCKER_HOST="tcp://${DOCKER_HOST_IP}:2375"
|
|
echo "DOCKER_HOST=$DOCKER_HOST"
|
|
|
|
# Login
|
|
echo "$REGISTRY_TOKEN" | docker login $REGISTRY -u luochen570 --password-stdin
|
|
|
|
# Build
|
|
docker build -t $REGISTRY/$IMAGE:${{ github.sha }} .
|
|
docker tag $REGISTRY/$IMAGE:${{ github.sha }} $REGISTRY/$IMAGE:latest
|
|
|
|
# Push
|
|
docker push $REGISTRY/$IMAGE:${{ github.sha }}
|
|
docker push $REGISTRY/$IMAGE:latest
|
|
|
|
- name: Deploy to k3s
|
|
run: |
|
|
echo "Deploy step - skipped until runner kubectl is configured"
|