Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d726553254 | ||
|
|
a66c3341d8 | ||
|
|
ade040c622 | ||
|
|
9384be3d8a | ||
|
|
cb0355b2d3 | ||
|
|
a59bf54e56 | ||
|
|
a82e7e9c26 | ||
|
|
1e81261aef | ||
|
|
c0975a75ed |
@@ -13,15 +13,14 @@ on:
|
|||||||
env:
|
env:
|
||||||
PATH: /opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
PATH: /opt/node/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||||
REGISTRY: registry.cn-chengdu.aliyuncs.com
|
REGISTRY: registry.cn-chengdu.aliyuncs.com
|
||||||
IMAGE_NAME: bamanker/myk3stest
|
IMAGE_NAMESPACE: bamanker
|
||||||
|
IMAGE_NAME: myk3stest
|
||||||
APP_NAME: myk3s-test
|
APP_NAME: myk3s-test
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# 构建 Job
|
# 构建 Job
|
||||||
build:
|
build:
|
||||||
runs-on: host
|
runs-on: host
|
||||||
outputs: # 声明作业的输出变量,方便在其他 Job 引用
|
|
||||||
datetime: ${{ steps.datetime.outputs.datetime }}
|
|
||||||
steps:
|
steps:
|
||||||
# 下载仓库源码,依赖java环境,因此构建服务器本地需要下载安装java并设置环境变量
|
# 下载仓库源码,依赖java环境,因此构建服务器本地需要下载安装java并设置环境变量
|
||||||
- name: Checkout repository code
|
- name: Checkout repository code
|
||||||
@@ -37,20 +36,21 @@ jobs:
|
|||||||
id: get_version
|
id: get_version
|
||||||
# e.g. refs/tags/v1.0.0
|
# e.g. refs/tags/v1.0.0
|
||||||
run: |
|
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
|
# - name: Check java version
|
||||||
# run: java -version
|
# run: java -version
|
||||||
|
|
||||||
|
|
||||||
- name: Set Env Var
|
- name: Set Env Var
|
||||||
env:
|
|
||||||
TAG: ${{ steps.get_version.outputs.version }}
|
|
||||||
run: |
|
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 }} |
|
# echo APP_TAG=${{ env.TAG }} |
|
||||||
# export APP_NAME=${{ env.APP_NAME }} |
|
# export APP_NAME=${{ env.APP_NAME }} |
|
||||||
# echo APP_NAME=${{ env.APP_NAME }} |
|
# echo APP_NAME=${{ env.APP_NAME }} |
|
||||||
- name: Inject Env Var
|
- name: Inject Env Var
|
||||||
run: |
|
run: |
|
||||||
envsubst < .deploy/deployment.yml
|
envsubst < ./deployment.yml
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
# 设置Maven执行权限,使用maven绝对路径执行打包命令
|
# 设置Maven执行权限,使用maven绝对路径执行打包命令
|
||||||
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
|
run: /usr/local/maven/bin/mvn clean package -DskipTests -Pprod
|
||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
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
|
- name: k8s Check and Apply New Deployment
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ spec:
|
|||||||
version: $APP_TAG
|
version: $APP_TAG
|
||||||
spec:
|
spec:
|
||||||
containers:
|
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
|
name: $APP_NAME
|
||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
30
pom.xml
30
pom.xml
@@ -8,9 +8,10 @@
|
|||||||
<version>4.0.1</version>
|
<version>4.0.1</version>
|
||||||
<relativePath/> <!-- lookup parent from repository -->
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>com.bamanker</groupId>
|
<groupId>com.bamanker</groupId>
|
||||||
<artifactId>myk3sTest</artifactId>
|
<artifactId>myk3sTest</artifactId>
|
||||||
<version>0.0.1</version>
|
<version>v1.1.9</version>
|
||||||
<name>myk3sTest</name>
|
<name>myk3sTest</name>
|
||||||
<description>myk3sTest</description>
|
<description>myk3sTest</description>
|
||||||
<url/>
|
<url/>
|
||||||
@@ -28,11 +29,13 @@
|
|||||||
</scm>
|
</scm>
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>25</java.version>
|
<java.version>25</java.version>
|
||||||
|
<app.version>${version}</app.version>
|
||||||
|
<app.name>${artifactId}</app.name>
|
||||||
<maven.compiler.source>25</maven.compiler.source>
|
<maven.compiler.source>25</maven.compiler.source>
|
||||||
<maven.compiler.target>25</maven.compiler.target>
|
<maven.compiler.target>25</maven.compiler.target>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -59,7 +62,27 @@
|
|||||||
|
|
||||||
<build>
|
<build>
|
||||||
<finalName>myk3sTest</finalName>
|
<finalName>myk3sTest</finalName>
|
||||||
|
<!--指定filtering=true.maven的占位符解析表达式就可以用于它里面的文件-->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<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>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
@@ -77,13 +100,11 @@
|
|||||||
</path>
|
</path>
|
||||||
</annotationProcessorPaths>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
|
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>
|
<exclude>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
@@ -94,5 +115,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
Reference in New Issue
Block a user