Compare commits
10 Commits
8de7107617
...
06d7e193ea
Author | SHA1 | Date | |
---|---|---|---|
06d7e193ea | |||
bb1998ea21 | |||
873c000060 | |||
774123eefc | |||
9a959b4cae | |||
ea770f4ae8 | |||
483296f906 | |||
30f452b44d | |||
e1c08e261a | |||
2843946171 |
@ -1,53 +0,0 @@
|
|||||||
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 }}
|
|
22
.gitea/workflows/ssh_test.yml
Normal file
22
.gitea/workflows/ssh_test.yml
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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