Compare commits
No commits in common. "06d7e193ea896a7650c053aadd69c27560dfdb7b" and "8de7107617661aaebef9b223555135547acf3652" have entirely different histories.
06d7e193ea
...
8de7107617
53
.gitea/workflows/docker_build.yml
Normal file
53
.gitea/workflows/docker_build.yml
Normal file
@ -0,0 +1,53 @@
|
||||
name: Build and Run Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "**" # 匹配所有分支
|
||||
paths-ignore: # 忽略一些不必要的文件
|
||||
- ".gitignore"
|
||||
- "README.md"
|
||||
- ".vscode/**"
|
||||
pull_request:
|
||||
branches: ["main"]
|
||||
|
||||
env:
|
||||
IMAGE_NAME: ${{ gitea.repository }}
|
||||
|
||||
jobs:
|
||||
build-and-run:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
steps:
|
||||
- name: 检出代码
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: 获取分支名称
|
||||
id: branch_name
|
||||
run: |
|
||||
# 从 GITHUB_REF 提取分支名
|
||||
branch=${GITHUB_REF#refs/heads/}
|
||||
echo "branch=$branch" >> $GITHUB_OUTPUT
|
||||
# 如果是 main 分支,使用 prod 标签,否则使用 dev-分支名
|
||||
if [ "$branch" = "main" ]; then
|
||||
echo "env_suffix=prod" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "env_suffix=dev-${branch}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: 设置 Docker 镜像标签
|
||||
id: docker_tags
|
||||
run: |
|
||||
echo "tag=${{ env.IMAGE_NAME }}:${{ steps.branch_name.outputs.env_suffix }}" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: 构建 Docker 镜像
|
||||
run: |
|
||||
docker build -t ${{ steps.docker_tags.outputs.tag }} .
|
||||
|
||||
- name: 运行 Docker 容器
|
||||
run: |
|
||||
docker run -d --name catface_${{ steps.branch_name.outputs.env_suffix }} \
|
||||
-p 20201:20201 \
|
||||
${{ steps.docker_tags.outputs.tag }}
|
@ -1,22 +0,0 @@
|
||||
name: SSH 连接测试
|
||||
|
||||
on:
|
||||
workflow_dispatch: # 手动触发
|
||||
push:
|
||||
branches:
|
||||
- main # 仅main分支触发
|
||||
|
||||
jobs:
|
||||
ssh-test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: SSH 连接测试
|
||||
uses: appleboy/ssh-action@master
|
||||
with:
|
||||
host: 120.27.198.238
|
||||
username: root
|
||||
password: Havocantelope420#
|
||||
port: '22'
|
||||
script: |
|
||||
echo "Running command on remote server"
|
||||
ls -lha
|
Loading…
x
Reference in New Issue
Block a user