Compare commits

...

15 Commits

Author SHA1 Message Date
bamanker
078fdf969e fix readinessProbe http path
All checks were successful
Build Push and Deploy Image / build (push) Successful in 4m35s
2025-12-28 17:08:44 +08:00
bamanker
e428f7a05c fix 2025-12-26 17:49:55 +08:00
bamanker
d694d0f7ab 修复端口号错误
Some checks failed
Build Push and Deploy Image / build (push) Failing after 36s
2025-12-26 17:07:01 +08:00
bamanker
2cc70877a0 直接用本地kubectl
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1m7s
2025-12-26 17:04:07 +08:00
bamanker
44c6fab1f4 更换kubectl action,修复了bug3
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1m17s
2025-12-26 16:37:45 +08:00
bamanker
cf924d1ee7 更换kubectl action,修复了bug1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 47s
2025-12-26 16:04:13 +08:00
bamanker
d97d39e5c4 更换kubectl action,修复了bug
Some checks failed
Build Push and Deploy Image / build (push) Failing after 30s
2025-12-26 15:51:23 +08:00
bamanker
55f57f9085 更换kubectl action
All checks were successful
Build Push and Deploy Image / build (push) Successful in 2m7s
2025-12-26 15:42:05 +08:00
bamanker
0389942e4f debug22
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 15:00:39 +08:00
bamanker
bc853144b8 debug21
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 14:57:57 +08:00
bamanker
f5b1de075f add 显示注入后的deployment文件
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1m14s
2025-12-26 12:50:09 +08:00
bamanker
24df5cd7d6 修复了一个小问题
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 12:45:45 +08:00
bamanker
6ed61c6501 修复传递环境变量不成功的问题1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 13s
2025-12-26 12:43:23 +08:00
bamanker
f677828aae 修复传递环境变量不成功的问题
Some checks failed
Build Push and Deploy Image / build (push) Failing after 14s
2025-12-26 12:19:43 +08:00
bamanker
29f1bc8aa1 传递环境变量20
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 12:00:41 +08:00
2 changed files with 40 additions and 50 deletions

View File

@@ -10,51 +10,48 @@ on:
# - main
workflow_dispatch: #手动构建h
#设置全局环境变量
env:
PATH: /opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REGISTRY: registry.cn-chengdu.aliyuncs.com
IMAGE_NAMESPACE: bamanker
REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
IMAGE_NAMESPACE: bamanker # todo 可以通过读取pom文件获取下面这些属性值
IMAGE_NAME: myk3stest
APP_NAME: myk3s-test
# 构建 Job
jobs:
# 构建 Job
build:
runs-on: host
steps:
# 下载仓库源码,依赖java环境,因此构建服务器本地需要下载安装java并设置环境变量
# 下载仓库源码,依赖node环境,因此构建服务器本地需要下载安装node并设置环境变量
- name: Checkout repository code
#使用自定义仓库action
uses: http://139.9.216.111:3000/bamanker/checkout@v6
# - name: Set up Java
# uses: https://gitee.com/bamanker/setup-java@v5
# with:
# java-version: '25.0.1'
# distribution: 'openjdk'
# cache: 'maven'
#检查tag
# 获取 TAG 并设置为环境变量
- name: Get version
id: get_version
# e.g. refs/tags/v1.0.0
run: |
echo "version=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_OUTPUT
# - name: Check java version
# run: java -version
echo "APP_TAG=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_ENV
# 检查 TAG 并传参
- name: Set envVar
id: set_envar
run: |
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT &&
echo "now workspace: ${{ github.workspace }}" &&
pwd
- name: Set Env Var
env:
APP_VERSION: ${{ steps.get_version.outputs.version }}
# 为其他配置文件注入环境变量
- name: Inject envVar
run: |
echo "The app version is $APP_VERSION" && export APP_TAG=$APP_VERSION
# export APP_TAG=$env.TAG
# echo APP_TAG=${{ env.TAG }} |
# export APP_NAME=${{ env.APP_NAME }} |
# echo APP_NAME=${{ env.APP_NAME }} |
- name: Inject Env Var
run: |
envsubst < ./deployment.yml
envsubst < ./deployment-temp.yml > ./deployment.yml &&
cat ./deployment.yml
# 构建java项目
- name: Build with Maven
# 设置Maven执行权限使用maven绝对路径执行打包命令
#使用maven绝对路径执行打包命令
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
# 登录镜像仓库,方便后续上传镜像
@@ -66,40 +63,33 @@ jobs:
# 这里也可以通过 secrets 传入,后面再介绍
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# 获取时间戳
- name: Get datetime
id: datetime
run: |
echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
# # 获取时间戳
# - name: Get datetime
# id: datetime
# run: |
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
# 构建并上传镜像
- name: Build and push Docker image
uses: http://139.9.216.111:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
#只能这样接收
env:
TAG: ${{ steps.get_version.outputs.version }}
TAG: ${{ steps.set_envar.outputs.tag }}
with:
context: .
platforms: linux/amd64
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
- name: k8s Check and Apply New Deployment
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
with:
config: ${{ secrets.KUBE_CONFIG }}
command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment.yml
#发布到 k8s
- name: Generate kubeconfig and deploy
run: kubectl apply -f ./deployment.yml
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
- name: k8s Check Pods Health
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
with:
config: ${{ secrets.KUBE_CONFIG }}
command: get pod -n default -l app=${{ env.APP_NAME }}
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
- name: k8s Update Deployment
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
command: rollout restart deployment ${{ env.APP_NAME }}-${{ gitea.ref_name }}
run: kubectl rollout restart deployment ${{ env.APP_NAME }}

View File

@@ -31,7 +31,7 @@ spec:
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /actuator/health
path: /test
port: 9090
initialDelaySeconds: 1
timeoutSeconds: 10
@@ -56,6 +56,6 @@ spec:
- name: http
protocol: TCP
port: 9090
nodePort: 9090
nodePort: 30909
selector:
app: $APP_NAME