ci-8
This commit is contained in:
parent
8de7107617
commit
2843946171
@ -1,4 +1,4 @@
|
|||||||
name: Build and Run Docker Image
|
name: Build and Push Docker Image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
@ -12,15 +12,25 @@ on:
|
|||||||
branches: ["main"]
|
branches: ["main"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
|
REGISTRY: http://113.44.68.213:3000
|
||||||
IMAGE_NAME: ${{ gitea.repository }}
|
IMAGE_NAME: ${{ gitea.repository }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-run:
|
build-and-push:
|
||||||
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 }}
|
||||||
|
exho ${{ secrets.GHCR_USER }}
|
||||||
|
echo ${{ secrets.GHCR_TOKEN }}
|
||||||
|
echo ${{ env.IMGAE_NAME }}
|
||||||
|
|
||||||
- name: 检出代码
|
- name: 检出代码
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
@ -37,17 +47,38 @@ jobs:
|
|||||||
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: 设置 Docker 镜像标签
|
- name: 登录到 Gitea Container Registry
|
||||||
id: docker_tags
|
uses: docker/login-action@v3
|
||||||
run: |
|
with:
|
||||||
echo "tag=${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.env_suffix }}" >> $GITHUB_OUTPUT
|
registry: ghcr.io
|
||||||
|
username: ${{ secrets.GHCR_USER }}
|
||||||
|
password: ${{ secrets.GHCR_TOKEN }}
|
||||||
|
# insecure: true # 允许 HTTP 连接 # Err: 无效
|
||||||
|
|
||||||
- name: 构建 Docker 镜像
|
# - name: 提取 Docker 元数据
|
||||||
run: |
|
# id: meta
|
||||||
docker build -t ${{ steps.docker_tags.outputs.tag }} .
|
# 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 容器
|
# - name: 构建并推送 Docker 镜像
|
||||||
run: |
|
# uses: docker/build-push-action@v5
|
||||||
docker run -d --name catface_${{ steps.branch_name.outputs.env_suffix }} \
|
# with:
|
||||||
-p 20201:20201 \
|
# context: .
|
||||||
${{ steps.docker_tags.outputs.tag }}
|
# 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 }}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user