Compare commits

..

2 Commits

Author SHA1 Message Date
0f97d71a6b change gitea action
Some checks failed
Gitea Actions Demo / host-commands (push) Has been cancelled
2026-02-15 19:16:42 +08:00
a7d5306acc db: add table article 2026-02-15 15:27:21 +08:00
6 changed files with 134 additions and 23 deletions

View File

@ -3,28 +3,12 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on: [push] on: [push]
jobs: jobs:
deploy: # 一个直接在宿主机上执行的 Job
runs-on: ubuntu-latest host-commands:
container: runs-on: self-hosted # 需要有一个标签为 self-hosted 的 runner 运行在宿主机上
image: gitea/runner-images:ubuntu-latest
steps: steps:
- name: clone project code - name: 在宿主机上执行命令
run: git clone ${{ gitea.server_url }}/${{ gitea.repository }} .
- name: List files
run: ls -la
- name: Stop running containers
run: | run: |
docker compose down || true echo "This command runs directly on the host machine"
- name: Remove old image # 例如:检查宿主机内核版本
run: | uname -a
IMAGE_NAME=$(basename "$PWD")
echo "Removing old image: $IMAGE_NAME"
docker images | grep "$IMAGE_NAME" && docker rmi -f $(docker images "$IMAGE_NAME" -q) || echo "No old image found."
- name: Build new image
run: |
docker build -t $(basename "$PWD"):latest .
- name: Start containers
run: |
docker compose up -d
- name: Show container status
run: docker ps

View File

@ -7,6 +7,7 @@ from alembic import context
from models.base import Base from models.base import Base
import models.source_content # 导入模型以注册到 Base.metadata import models.source_content # 导入模型以注册到 Base.metadata
import models.article # 导入模型以注册到 Base.metadata
# this is the Alembic Config object, which provides # this is the Alembic Config object, which provides
# access to the values within the .ini file in use. # access to the values within the .ini file in use.

View File

@ -0,0 +1,42 @@
"""add table article
Revision ID: 7de2da2e824b
Revises: dfad2ce9d3b7
Create Date: 2026-02-15 15:11:54.662014
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '7de2da2e824b'
down_revision: Union[str, Sequence[str], None] = 'dfad2ce9d3b7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('t_article',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False, comment='自动递增的唯一内容ID'),
sa.Column('title', sa.String(length=256), nullable=False, comment='标题'),
sa.Column('keywords', sa.Text(), nullable=True, comment='关键词'),
sa.Column('content', sa.Text(), nullable=True, comment='内容'),
sa.Column('create_time', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False, comment='创建时间'),
sa.Column('used', sa.Boolean(), nullable=False, comment='是否已被使用'),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_t_article_title'), 't_article', ['title'], unique=False)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_t_article_title'), table_name='t_article')
op.drop_table('t_article')
# ### end Alembic commands ###

View File

@ -0,0 +1,32 @@
"""add table article
Revision ID: dfad2ce9d3b7
Revises: fc8b7693c66b
Create Date: 2026-02-15 15:09:51.788382
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'dfad2ce9d3b7'
down_revision: Union[str, Sequence[str], None] = 'fc8b7693c66b'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
pass
# ### end Alembic commands ###

2
models/__init__.py Normal file
View File

@ -0,0 +1,2 @@
from models.source_content import SourceContent
from models.article import Article

50
models/article.py Normal file
View File

@ -0,0 +1,50 @@
from datetime import datetime
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String, Text, Integer, DateTime, func
from models.base import Base
class Article(Base):
__tablename__ = "t_article"
id: Mapped[int] = mapped_column(
Integer,
primary_key=True,
autoincrement=True,
comment="自动递增的唯一内容ID"
)
title: Mapped[str] = mapped_column(
String(256),
nullable=False,
index=True,
comment="标题"
)
keywords: Mapped[str | None] = mapped_column(
Text,
nullable=True,
comment="关键词"
)
content: Mapped[str | None] = mapped_column(
Text,
nullable=True,
comment="内容"
)
create_time: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
server_default=func.now(),
nullable=False,
comment="创建时间"
)
used: Mapped[bool] = mapped_column(
default=False,
nullable=False,
comment="是否已被使用"
)
def __repr__(self):
return f"<Article id={self.id} title={self.title!r} used={self.used!r}>"