Compare commits

..

19 Commits

Author SHA1 Message Date
bamanker
a83edb9479 传递环境变量19
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 11:15:39 +08:00
bamanker
2bf5e16dcd 传递环境变量18
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 11:12:02 +08:00
bamanker
d726553254 传递环境变量17
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 11:03:07 +08:00
bamanker
a66c3341d8 传递环境变量16 2025-12-26 11:01:51 +08:00
bamanker
ade040c622 传递环境变量15
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 10:57:34 +08:00
bamanker
9384be3d8a 传递环境变量14
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 10:47:13 +08:00
bamanker
cb0355b2d3 传递环境变量13
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 10:45:29 +08:00
bamanker
a59bf54e56 传递环境变量12
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 10:20:13 +08:00
bamanker
a82e7e9c26 传递环境变量11
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 10:03:49 +08:00
bamanker
1e81261aef 传递环境变量10
Some checks failed
Build Push and Deploy Image / build (push) Failing after 2s
2025-12-26 10:02:07 +08:00
bamanker
c0975a75ed 传递环境变量9
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 09:57:51 +08:00
bamanker
10153898c2 传递环境变量8
Some checks failed
Build Push and Deploy Image / build (push) Failing after 2s
2025-12-26 09:56:48 +08:00
bamanker
8412554d26 传递环境变量7
Some checks failed
Build Push and Deploy Image / build (push) Has been cancelled
2025-12-26 09:51:14 +08:00
bamanker
8555ea3077 传递环境变量6
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1s
2025-12-26 09:50:18 +08:00
bamanker
79471c11a5 传递环境变量5
Some checks failed
Build Push and Deploy Image / build (push) Failing after 1s
2025-12-26 09:46:29 +08:00
bamanker
11c1c2fa23 传递环境变量4 2025-12-26 09:43:54 +08:00
bamanker
90e4fb4e96 传递环境变量3 2025-12-26 09:42:31 +08:00
bamanker
3dab5fc361 传递环境变量2 2025-12-26 09:38:54 +08:00
bamanker
a2cea3ca9a 传递环境变量1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 2s
2025-12-26 09:36:22 +08:00
3 changed files with 41 additions and 19 deletions

View File

@@ -13,15 +13,14 @@ on:
env:
PATH: /opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
REGISTRY: registry.cn-chengdu.aliyuncs.com
IMAGE_NAME: bamanker/myk3stest
IMAGE_NAMESPACE: bamanker
IMAGE_NAME: myk3stest
APP_NAME: myk3s-test
jobs:
# 构建 Job
build:
runs-on: host
outputs: # 声明作业的输出变量,方便在其他 Job 引用
datetime: ${{ steps.datetime.outputs.datetime }}
steps:
# 下载仓库源码依赖java环境因此构建服务器本地需要下载安装java并设置环境变量
- name: Checkout repository code
@@ -32,25 +31,28 @@ jobs:
# java-version: '25.0.1'
# distribution: 'openjdk'
# cache: 'maven'
#检查java版本
#检查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
# - name: Check java version
# run: java -version
- name: Set Env Var
env:
TAG: ${{ steps.get_version.outputs.version }}
APP_VERSION: ${{ steps.get_version.outputs.version }}
run: |
export APP_TAG=${{ env.TAG }} |
echo "APP_TAG=${{ env.TAG }}" |
export APP_NAME=${{ env.APP_NAME }} |
echo "APP_NAME=${{ env.APP_NAME }}" |
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 < .deploy/deployment.yml
envsubst < ./deployment.yml
- name: Build with Maven
# 设置Maven执行权限使用maven绝对路径执行打包命令
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
@@ -80,7 +82,7 @@ jobs:
platforms: linux/amd64
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
- name: k8s Check and Apply New Deployment

View File

@@ -26,7 +26,7 @@ spec:
version: $APP_TAG
spec:
containers:
- image: registry.cn-chengdu.aliyuncs.com/bamanker/myk3stest:$APP_TAG #$REGISTRY/$DOCKERHUB_NAMESPACE/$APP_NAME
- image: $REGISTRY/$IMAGE_NAMESPACE/$IMAGE_NAME:$APP_TAG
name: $APP_NAME
imagePullPolicy: Always
readinessProbe:

30
pom.xml
View File

@@ -8,9 +8,10 @@
<version>4.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.bamanker</groupId>
<artifactId>myk3sTest</artifactId>
<version>0.0.1</version>
<version>v1.1.9</version>
<name>myk3sTest</name>
<description>myk3sTest</description>
<url/>
@@ -28,11 +29,13 @@
</scm>
<properties>
<java.version>25</java.version>
<app.version>${version}</app.version>
<app.name>${artifactId}</app.name>
<maven.compiler.source>25</maven.compiler.source>
<maven.compiler.target>25</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
@@ -59,7 +62,27 @@
<build>
<finalName>myk3sTest</finalName>
<!--指定filtering=true.maven的占位符解析表达式就可以用于它里面的文件-->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<!--支持yaml读取pom的参数-->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<encoding>UTF-8</encoding>
<delimiters>
<delimiter>@</delimiter>
</delimiters>
<useDefaultDelimiters>false</useDefaultDelimiters>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
@@ -77,13 +100,11 @@
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
@@ -94,5 +115,4 @@
</plugin>
</plugins>
</build>
</project>