Compare commits

...

18 Commits

Author SHA1 Message Date
bamanker
3cf282b964 修改kubectl命令错误
All checks were successful
Build Push and Deploy Image / build (push) Successful in 21m34s
2026-01-05 14:58:04 +08:00
bamanker
e3a7e3c2b3 修改一些小错误
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21m24s
2026-01-05 14:22:19 +08:00
bamanker
c052a11c4b 更改kubectl的action为手动下载2
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21m20s
2026-01-04 23:08:07 +08:00
bamanker
4baa013d02 更改kubectl的action为手动下载1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 22m5s
2026-01-04 22:43:23 +08:00
bamanker
6e1ec6a761 更改kubectl的action为手动下载
Some checks failed
Build Push and Deploy Image / build (push) Failing after 24m41s
2026-01-04 22:10:59 +08:00
bamanker
7ebd4ba157 更改kubectl的action2
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21m41s
2026-01-04 18:01:36 +08:00
bamanker
75d0f8d768 更改kubectl的action1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 24m48s
2026-01-04 17:15:47 +08:00
bamanker
afa97145c1 更改kubectl的action
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21m57s
2026-01-04 16:13:16 +08:00
bamanker
2f39836963 修复mount source: "overlay" 错误的问题 5
Some checks failed
Build Push and Deploy Image / build (push) Failing after 21m14s
2026-01-04 15:19:05 +08:00
bamanker
d9807291ad 修复mount source: "overlay" 错误的问题 4
Some checks failed
Build Push and Deploy Image / build (push) Failing after 2m19s
2026-01-04 14:59:41 +08:00
bamanker
27c3ab7b82 修复mount source: "overlay" 错误的问题 3
Some checks failed
Build Push and Deploy Image / build (push) Failing after 24s
2026-01-04 14:58:27 +08:00
bamanker
67ce2b5c86 修复mount source: "overlay" 错误的问题 2
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2026-01-04 14:03:19 +08:00
bamanker
be67a8fef0 修复mount source: "overlay" 错误的问题 1
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2026-01-04 13:09:17 +08:00
bamanker
6b47cfd5f8 修复mount source: "overlay" 错误的问题 1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 2m11s
2026-01-04 12:55:38 +08:00
bamanker
d5ab5e6727 修复mount source: "overlay", target 错误的问题
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1m25s
2026-01-04 12:51:32 +08:00
bamanker
adcf60eeb6 修改了dockerfile中的基础镜像2
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1m12s
2026-01-04 12:23:20 +08:00
bamanker
5b20c46c5d 修改了dockerfile中的基础镜像1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 20m34s
2026-01-04 11:37:15 +08:00
bamanker
472edfaabd 修改了dockerfile中的基础镜像
Some checks failed
Build Push and Deploy Image / build (push) Failing after 23m17s
2026-01-04 10:55:40 +08:00
2 changed files with 58 additions and 32 deletions

View File

@@ -21,27 +21,41 @@ env:
# 构建 Job
jobs:
build:
runs-on: ubuntu-node22 # 如果host构建 linux_amd64
runs-on: ubuntu-node22 # 如果host构建:linux_amd64
# container:
# image: swr.cn-north-4.myhuaweicloud.com/ddn-k8s/ghcr.io/catthehacker/ubuntu:act-latest
steps:
- name: Print system info 1
run: echo " The job was automatically triggered by a ${{ gitea.event_name }} event."
- name: Print system info 2
run: echo " This job is now running on a ${{ runner.os }} server hosted by Gitea!"
- name: Print system info 3
run: echo " The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: Print env
run: env
run: env && blkid
- name: Install dependencies
run: |
apt-get update &&
apt-get install -y gettext &&
apt-get install -y maven &&
apt-get install -y sudo &&
apt-get install -y iptables
apt-get update &&
apt-get install -y gettext &&
apt-get install -y maven &&
apt-get install -y sudo &&
apt-get install -y iptables
- name: Set up Docker
uses: http://139.9.216.111:3000/bamanker/setup-docker-action@v4
uses: http://139.9.216.111:3000/bamanker/setup-docker-action@v4.6.0
with:
# 版本大于28会有兼容性问题
version: type=archive,channel=stable,version=v27.4.0
daemon-config: |
{
"registry-mirrors":["https://docker.1ms.run"],
"dns": ["8.8.8.8", "114.114.114.114"]
}
- name: Generate maven config
uses: http://139.9.216.111:3000/bamanker/maven-settings-action@v3.1.0
with:
@@ -54,9 +68,6 @@ jobs:
# - run: node -v
# 下载仓库源码依赖node环境因此构建服务器本地需要下载安装node并设置环境变量
# - name: Set up Docker Buildx
# uses: http://139.9.216.111:3000/bamanker/setup-buildx-action@v3
- name: Checkout repository code
#使用自定义仓库action
uses: http://139.9.216.111:3000/bamanker/checkout@v4
@@ -73,9 +84,7 @@ jobs:
id: set_envar
run: |
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT &&
echo "now workspace: ${{ github.workspace }}" &&
docker version &&
docker --help
echo "now workspace: ${{ github.workspace }}"
# 为其他配置文件注入环境变量
- name: Inject envVar
@@ -83,16 +92,15 @@ jobs:
envsubst < ./deployment-temp.yml > ./deployment.yml &&
cat ./deployment.yml
# 构建java项目
# 安装java环境
- name: Set up Java
uses: http://139.9.216.111:3000/bamanker/setup-graalvm@v1
with:
distribution: 'graalvm'
java-version: '25.0.1'
cache: 'maven'
# maven 构建
- name: Build with Maven
#使用maven绝对路径执行打包命令
run: mvn clean native:compile -DskipTests -Pnative
# 登录镜像仓库,方便后续上传镜像
@@ -101,7 +109,6 @@ jobs:
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
# 这里也可以通过 secrets 传入,后面再介绍
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# # 获取时间戳
@@ -110,17 +117,18 @@ jobs:
# run: |
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
# 构建并上传镜像 TODO 直接用docker命令操作
# 构建并上传镜像
- name: Build and push Docker image
# uses: http://139.9.216.111:3000/bamanker/build-push-action@v4 # 获取上一步截取到的版本号,既 1.0.0
# uses: http://139.9.216.111:3000/bamanker/build-push-action@v4
# 获取上一步截取到的版本号,既 1.0.0
#只能这样接收
env:
TAG: ${{ steps.set_envar.outputs.tag }}
run: |
ls &&
docker build --file Dockerfile --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} . &&
docker image ls
# ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} --push.
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
# uses: http://139.9.216.111:3000/bamanker/docker-build-push@v5
# with:
# context: .
@@ -130,17 +138,35 @@ jobs:
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
#发布到 k8s
- name: Generate kubeconfig
uses: http://139.9.216.111:3000/bamanker/kubectl-action@v1.4.0
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
- name: Deploy k8s
run: kubectl apply -f ./deployment.yml
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
#安装 kubectl
- name: Setup kubectl
run: |
curl -LO "https://dl.k8s.io/release/v1.33.0/bin/linux/amd64/kubectl" &&
chmod +x kubectl &&
mv kubectl /usr/local/bin/
- name: Configure kubeconfig
# 假设您的 KUBE_CONFIG 秘密是 Base64 编码的 kubeconfig 文件内容
run: |
# 1. 创建 ~/.kube 目录
mkdir -p $HOME/.kube
# 2. 将 Base64 编码的 KUBE_CONFIG 秘密解码并写入默认配置文件
echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config
# 3. 确保 kubectl 知道配置文件的位置 (可选, 但安全)
echo "KUBECONFIG=$HOME/.kube/config" >> $GITHUB_ENV
- name: Deploy with kubectl
run: |
kubectl apply -f ./deployment.yml
- name: k8s Check Pods Health
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
run: |
kubectl get pod -n default -l app=${{ env.APP_NAME }}
- name: k8s Update Deployment
run: kubectl rollout restart deployment ${{ env.APP_NAME }}
run: |
kubectl rollout restart deployment ${{ env.APP_NAME }}

View File

@@ -1,5 +1,5 @@
# 基于 java25 构建
FROM ubuntu:jammy
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/ubuntu:jammy
# 基于构建上下文 . 进行COPY 文件到 /root目录下
COPY target/myk3sTest /root/myk3sTest/
EXPOSE 9090