ci-4
This commit is contained in:
parent
d070c79d4b
commit
8de7107617
@ -1,4 +1,4 @@
|
||||
name: Build and Push Docker Image
|
||||
name: Build and Run Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
@ -12,24 +12,15 @@ on:
|
||||
branches: ["main"]
|
||||
|
||||
env:
|
||||
REGISTRY: 113.44.68.213:3000
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-push:
|
||||
build-and-run:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
steps:
|
||||
- name: 获取 Gitea 配置
|
||||
run: |
|
||||
echo ${{ env.REGISTRY }}
|
||||
echo ${{ gitea.actor }}
|
||||
echo ${{ secrets.DOCKER_TOKEN }}
|
||||
echo ${{ env.IMGAE_NAME }}
|
||||
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@ -44,40 +35,19 @@ jobs:
|
||||
echo "env_suffix=prod" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: 登录到 Gitea Container Registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ gitea.actor }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
insecure: true # 允许 HTTP 连接
|
||||
- name: 设置 Docker 镜像标签
|
||||
id: docker_tags
|
||||
run: |
|
||||
echo "tag=${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.env_suffix }}" >> $GITHUB_OUTPUT
|
||||
|
||||
# - name: 提取 Docker 元数据
|
||||
# id: meta
|
||||
# uses: docker/metadata-action@v5
|
||||
# with:
|
||||
# images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||
# tags: |
|
||||
# # main 分支使用标准标签
|
||||
# type=raw,value=latest,enable=${{ steps.branch_name.outputs.branch == 'main' }}
|
||||
# type=raw,value=${{ steps.branch_name.outputs.env_suffix }}
|
||||
# type=sha,format=short,prefix=${{ steps.branch_name.outputs.env_suffix }}-
|
||||
# type=ref,event=tag,prefix=${{ steps.branch_name.outputs.env_suffix }}-
|
||||
- name: 构建 Docker 镜像
|
||||
run: |
|
||||
docker build -t ${{ steps.docker_tags.outputs.tag }} .
|
||||
|
||||
# - name: 构建并推送 Docker 镜像
|
||||
# uses: docker/build-push-action@v5
|
||||
# with:
|
||||
# context: .
|
||||
# push: true
|
||||
# tags: ${{ steps.meta.outputs.tags }}
|
||||
# labels: ${{ steps.meta.outputs.labels }}
|
||||
# build-args: |
|
||||
# BUILDKIT_INLINE_CACHE=0
|
||||
# # 添加清理缓存的命令
|
||||
# outputs: type=docker,cleancache=true
|
||||
|
||||
# - name: Trigger Portainer Webhook
|
||||
# run: |
|
||||
# curl -k -X POST ${{ secrets.BACKEND_WEBHOOK_URL }}
|
||||
- name: 运行 Docker 容器
|
||||
run: |
|
||||
docker run -d --name catface_${{ steps.branch_name.outputs.env_suffix }} \
|
||||
-p 20201:20201 \
|
||||
${{ steps.docker_tags.outputs.tag }}
|
Loading…
x
Reference in New Issue
Block a user