Files
admin-ui/.gitea/workflows/deploy-k3s.yml
张斌 e20ee8e065
Some checks failed
部署 admin-ui 到 K3s / deploy (push) Failing after 7s
https证书替换
2026-06-02 17:58:50 +08:00

45 lines
1.5 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 工作流名称
name: 部署到 K3s
# 触发条件:推送到 main 分支时执行
on:
push:
branches: [ main ]
# 定义任务
jobs:
deploy:
# 运行环境(默认 Ubuntu
runs-on: ubuntu-latest
steps:
# 步骤1拉取仓库代码必选
- name: 拉取代码
uses: actions/checkout@v4
# 步骤2安装 kubectl修复 command not found
- name: 安装 kubectl
run: |
# 下载适配 K3s 的 kubectl 版本v1.28.0 可根据你的 K3s 版本调整)
curl -LO "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/
# 验证安装
kubectl version --client
# --------------------------
# 步骤4配置 K3s 集群访问(就在这里!)
# --------------------------
- name: 配置 K3s 集群访问
run: |
# 创建 kubectl 配置目录
mkdir -p ~/.kube
# 将 Gitea 秘钥中的 kubeconfig 内容写入文件
echo "${{ secrets.KUBECONFIG_CONTENT }}" > ~/.kube/config
# 赋予配置文件正确权限kubectl 要求权限不能太开放)
chmod 600 ~/.kube/config
# 验证是否能连接到 K3s 集群(可选,用于调试)
kubectl get nodes
# 步骤5执行部署命令你的原有步骤
- name: 部署到 K3s 集群
run: |
kubectl apply -f k8s/