Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
078fdf969e | ||
|
|
e428f7a05c | ||
|
|
d694d0f7ab | ||
|
|
2cc70877a0 | ||
|
|
44c6fab1f4 | ||
|
|
cf924d1ee7 | ||
|
|
d97d39e5c4 | ||
|
|
55f57f9085 | ||
|
|
0389942e4f | ||
|
|
bc853144b8 | ||
|
|
f5b1de075f | ||
|
|
24df5cd7d6 | ||
|
|
6ed61c6501 |
@@ -28,24 +28,26 @@ jobs:
|
|||||||
#使用自定义仓库action
|
#使用自定义仓库action
|
||||||
uses: http://139.9.216.111:3000/bamanker/checkout@v6
|
uses: http://139.9.216.111:3000/bamanker/checkout@v6
|
||||||
|
|
||||||
# 获取 TAG
|
# 获取 TAG 并设置为环境变量
|
||||||
- name: Get version
|
- name: Get version
|
||||||
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 "APP_TAG=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_ENV
|
||||||
|
|
||||||
# 检查 TAG 设置为环境变量
|
# 检查 TAG 并传参
|
||||||
- name: Set envVar
|
- name: Set envVar
|
||||||
env:
|
id: set_envar
|
||||||
APP_VERSION: ${{ steps.get_version.outputs.version }}
|
|
||||||
run: |
|
run: |
|
||||||
echo "The app version is $APP_VERSION" && echo "APP_TAG=$APP_VERSION" >> $GITHUB_ENV
|
echo "The app version is $APP_TAG" && echo "tag=$APP_TAG" >> $GITHUB_OUTPUT &&
|
||||||
|
echo "now workspace: ${{ github.workspace }}" &&
|
||||||
|
pwd
|
||||||
|
|
||||||
# 为其他配置文件注入环境变量
|
# 为其他配置文件注入环境变量
|
||||||
- name: Inject envVar
|
- name: Inject envVar
|
||||||
run: |
|
run: |
|
||||||
envsubst < ./deployment-temp.yml > ./deployment.yml
|
envsubst < ./deployment-temp.yml > ./deployment.yml &&
|
||||||
|
cat ./deployment.yml
|
||||||
|
|
||||||
# 构建java项目
|
# 构建java项目
|
||||||
- name: Build with Maven
|
- name: Build with Maven
|
||||||
@@ -61,41 +63,33 @@ jobs:
|
|||||||
# 这里也可以通过 secrets 传入,后面再介绍
|
# 这里也可以通过 secrets 传入,后面再介绍
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
|
|
||||||
# # 获取时间戳
|
# # 获取时间戳
|
||||||
# - name: Get datetime
|
# - name: Get datetime
|
||||||
# id: datetime
|
# id: datetime
|
||||||
# run: |
|
# run: |
|
||||||
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
|
# echo "datetime=$(date '+%Y-%m-%d-%H-%M-%S')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# 构建并上传镜像
|
# 构建并上传镜像
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
uses: http://139.9.216.111:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
|
uses: http://139.9.216.111:3000/bamanker/build-push-action@v6 # 获取上一步截取到的版本号,既 1.0.0
|
||||||
|
#只能这样接收
|
||||||
env:
|
env:
|
||||||
TAG: $APP_TAG
|
TAG: ${{ steps.set_envar.outputs.tag }}
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
file: Dockerfile
|
file: Dockerfile
|
||||||
push: true
|
push: true
|
||||||
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
|
|
||||||
#发布到 k8s
|
#发布到 k8s
|
||||||
- name: k8s Check and Apply New Deployment
|
- name: Generate kubeconfig and deploy
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
run: kubectl apply -f ./deployment.yml
|
||||||
with:
|
# command: apply -f http://139.9.216.111:3000/bamanker/myk3sTest/raw/branch/master/.deploy/deployment-temp.yml
|
||||||
config: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
command: 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
|
- name: k8s Check Pods Health
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
run: kubectl get pod -n default -l app=${{ env.APP_NAME }}
|
||||||
with:
|
|
||||||
config: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
command: get pod -n default -l app=${{ env.APP_NAME }}
|
|
||||||
|
|
||||||
- name: k8s Update Deployment
|
- name: k8s Update Deployment
|
||||||
uses: http://139.9.216.111:3000/bamanker/steevchen-kubectl@master
|
run: kubectl rollout restart deployment ${{ env.APP_NAME }}
|
||||||
env:
|
|
||||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
|
||||||
with:
|
|
||||||
command: rollout restart deployment ${{ env.APP_NAME }}-${{ gitea.ref_name }}
|
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ spec:
|
|||||||
imagePullPolicy: Always
|
imagePullPolicy: Always
|
||||||
readinessProbe:
|
readinessProbe:
|
||||||
httpGet:
|
httpGet:
|
||||||
path: /actuator/health
|
path: /test
|
||||||
port: 9090
|
port: 9090
|
||||||
initialDelaySeconds: 1
|
initialDelaySeconds: 1
|
||||||
timeoutSeconds: 10
|
timeoutSeconds: 10
|
||||||
@@ -56,6 +56,6 @@ spec:
|
|||||||
- name: http
|
- name: http
|
||||||
protocol: TCP
|
protocol: TCP
|
||||||
port: 9090
|
port: 9090
|
||||||
nodePort: 9090
|
nodePort: 30909
|
||||||
selector:
|
selector:
|
||||||
app: $APP_NAME
|
app: $APP_NAME
|
||||||
|
|||||||
Reference in New Issue
Block a user