Compare commits

...

9 Commits

Author SHA1 Message Date
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
3 changed files with 35 additions and 15 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
@@ -37,20 +36,21 @@ jobs:
id: get_version
# e.g. refs/tags/v1.0.0
run: |
echo "version=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_OUTPUT
echo "version=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_OUTPUT && echo "APP_TAG=${{ steps.get_version.outputs.version }}"
# - name: Check java version
# run: java -version
- name: Set Env Var
env:
TAG: ${{ steps.get_version.outputs.version }}
run: |
export APP_TAG=${env.TAG} |
cat ./deployment.yml && export APP_TAG="${{ steps.get_version.outputs.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 +80,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>