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:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -12,24 +12,15 @@ on:
|
|||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: 113.44.68.213:3000
|
|
||||||
IMAGE_NAME: ${{ gitea.repository }}
|
IMAGE_NAME: ${{ gitea.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-run:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: 获取 Gitea 配置
|
|
||||||
run: |
|
|
||||||
echo ${{ env.REGISTRY }}
|
|
||||||
echo ${{ gitea.actor }}
|
|
||||||
echo ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
echo ${{ env.IMGAE_NAME }}
|
|
||||||
|
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@ -46,38 +37,17 @@ jobs:
|
|||||||
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 登录到 Gitea Container Registry
|
- name: 设置 Docker 镜像标签
|
||||||
uses: docker/login-action@v3
|
id: docker_tags
|
||||||
with:
|
run: |
|
||||||
registry: ${{ env.REGISTRY }}
|
echo "tag=${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.env_suffix }}" >> $GITHUB_OUTPUT
|
||||||
username: ${{ gitea.actor }}
|
|
||||||
password: ${{ secrets.DOCKER_TOKEN }}
|
|
||||||
insecure: true # 允许 HTTP 连接
|
|
||||||
|
|
||||||
# - name: 提取 Docker 元数据
|
- name: 构建 Docker 镜像
|
||||||
# id: meta
|
run: |
|
||||||
# uses: docker/metadata-action@v5
|
docker build -t ${{ steps.docker_tags.outputs.tag }} .
|
||||||
# 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 镜像
|
- name: 运行 Docker 容器
|
||||||
# uses: docker/build-push-action@v5
|
run: |
|
||||||
# with:
|
docker run -d --name catface_${{ steps.branch_name.outputs.env_suffix }} \
|
||||||
# context: .
|
-p 20201:20201 \
|
||||||
# push: true
|
${{ steps.docker_tags.outputs.tag }}
|
||||||
# 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 }}
|
|
Loading…
x
Reference in New Issue
Block a user