修复传递环境变量不成功的问题1
Some checks failed
Build Push and Deploy Image / build (push) Failing after 13s

This commit is contained in:
bamanker
2025-12-26 12:43:23 +08:00
parent f677828aae
commit 6ed61c6501

View File

@@ -28,19 +28,18 @@ jobs:
#使用自定义仓库action
uses: http://139.9.216.111:3000/bamanker/checkout@v6
# 获取 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
echo "APP_TAG=${GITHUB_REF/refs\/tags\/v}" >> $GITHUB_ENV
# 检查 TAG 设置为环境变量
# 检查 TAG 并传参
- name: Set envVar
env:
APP_VERSION: ${{ steps.get_version.outputs.version }}
id: set_envar
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
# 为其他配置文件注入环境变量
- name: Inject envVar
@@ -61,17 +60,18 @@ 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: $APP_TAG
TAG: ${{ steps.set_envar.outputs.tag }}
with:
context: .
platforms: linux/amd64
@@ -85,7 +85,7 @@ jobs:
with:
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
# 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: