From 7acf0002344abdce92beb00e26e591cfcb397dea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BC=96=E7=A0=81=E7=8C=BF?= Date: Sun, 5 Oct 2025 02:16:12 +0800 Subject: [PATCH] 33344 --- .gitea/workflows/test.yml | 43 +++++++++++--- config.yaml | 120 +++++++++++++++++++------------------- 2 files changed, 95 insertions(+), 68 deletions(-) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 394c807..293c199 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -1,19 +1,44 @@ +# 工作流名称 name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 + +# 运行名称:在Gitea界面中显示的具体运行名称,支持动态变量 +run-name: ${{ gitea.actor }} 正在测试 Gitea Actions 🚀 + +# 触发条件:当发生push事件时触发 on: [push] +# 作业定义 jobs: + # 作业名称:探索Gitea Actions Explore-Gitea-Actions: + # 运行环境:在ubuntu-latest标签的runner上运行 runs-on: ubuntu-latest + + # 步骤序列 steps: - - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code + # 步骤1:输出事件信息 + - run: echo "🎉 该作业由 ${{ gitea.event_name }} 事件自动触发。" + + # 步骤2:输出运行环境信息 + - run: echo "🐧 该作业现在正在Gitea托管的 ${{ runner.os }} 服务器上运行!" + + # 步骤3:输出分支和仓库信息 + - run: echo "🔎 您的分支名称是 ${{ gitea.ref }},您的仓库是 ${{ gitea.repository }}。" + + # 步骤4:检出仓库代码(具有名称的步骤) + - name: 检出仓库代码 uses: actions/checkout@v4 - - run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "🖥️ The workflow is now ready to test your code on the runner." - - name: List files in the repository + + # 步骤5:输出克隆完成信息 + - run: echo "💡 ${{ gitea.repository }} 仓库已克隆到runner。" + + # 步骤6:准备测试提示 + - run: echo "🖥️ 工作流现已准备好在runner上测试您的代码。" + + # 步骤7:列出仓库文件(多行命令) + - name: 列出仓库中的文件 run: | ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ job.status }}." \ No newline at end of file + + # 步骤8:输出作业状态 + - run: echo "🍏 此作业的状态是 ${{ job.status }}。" \ No newline at end of file diff --git a/config.yaml b/config.yaml index 8fe4448..8646131 100644 --- a/config.yaml +++ b/config.yaml @@ -4,107 +4,109 @@ # just run `./act_runner generate-config > config.yaml` to generate a config file. log: - # The level of logging, can be trace, debug, info, warn, error, fatal + # 日志级别,可选值:trace, debug, info, warn, error, fatal level: info runner: - # Where to store the registration result. + # 注册结果存储位置 file: .runner - # Execute how many tasks concurrently at the same time. + # 同时执行的任务并发数 capacity: 1 - # Extra environment variables to run jobs. + # 运行作业的额外环境变量 envs: A_TEST_ENV_NAME_1: a_test_env_value_1 A_TEST_ENV_NAME_2: a_test_env_value_2 - # Extra environment variables to run jobs from a file. - # It will be ignored if it's empty or the file doesn't exist. + # 从文件加载额外环境变量 + # 如果为空或文件不存在则忽略 env_file: .env - # The timeout for a job to be finished. - # Please note that the Gitea instance also has a timeout (3h by default) for the job. - # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. + # 作业完成的超时时间 + # 注意:Gitea 实例也有作业超时设置(默认3小时) + # 如果 Gitea 的超时时间更短,作业可能会被 Gitea 停止 timeout: 3h - # The timeout for the runner to wait for running jobs to finish when shutting down. - # Any running jobs that haven't finished after this timeout will be cancelled. + # 关闭时等待运行中作业完成的超时时间 + # 在此超时后仍未完成的运行中作业将被取消 shutdown_timeout: 0s - # Whether skip verifying the TLS certificate of the Gitea instance. + # 是否跳过验证 Gitea 实例的 TLS 证书 insecure: false - # The timeout for fetching the job from the Gitea instance. + # 从 Gitea 实例获取作业的超时时间 fetch_timeout: 5s - # The interval for fetching the job from the Gitea instance. + # 从 Gitea 实例获取作业的间隔时间 fetch_interval: 2s - # The github_mirror of a runner is used to specify the mirror address of the github that pulls the action repository. - # It works when something like `uses: actions/checkout@v4` is used and DEFAULT_ACTIONS_URL is set to github, - # and github_mirror is not empty. In this case, - # it replaces https://github.com with the value here, which is useful for some special network environments. + # 用于指定拉取 action 仓库的 GitHub 镜像地址 + # 当使用类似 `uses: actions/checkout@v4` 且 DEFAULT_ACTIONS_URL 设置为 github 时生效 + # 如果 github_mirror 不为空,会将 https://github.com 替换为此处的值 + # 这对某些特殊网络环境很有用 github_mirror: '' - # The labels of a runner are used to determine which jobs the runner can run, and how to run them. - # Like: "macos-arm64:host" or "ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest" - # Find more images provided by Gitea at https://gitea.com/docker.gitea.com/runner-images . - # If it's empty when registering, it will ask for inputting labels. - # If it's empty when execute `daemon`, will use labels in `.runner` file. + # runner 的标签用于确定可以运行哪些作业以及如何运行它们 + # 例如:"macos-arm64:host" 或 "ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest" + # 在 https://gitea.com/docker.gitea.com/runner-images 查找 Gitea 提供的更多镜像 + # 注册时如果为空,会要求输入标签 + # 执行 `daemon` 时如果为空,将使用 `.runner` 文件中的标签 labels: - "ubuntu-latest:docker://docker.gitea.com/runner-images:ubuntu-latest" - "ubuntu-22.04:docker://docker.gitea.com/runner-images:ubuntu-22.04" - "ubuntu-20.04:docker://docker.gitea.com/runner-images:ubuntu-20.04" + +# 作用:配置 Actions 缓存功能,加速依赖下载和构建过程 cache: - # Enable cache server to use actions/cache. + # 启用缓存服务器以使用 actions/cache enabled: true - # The directory to store the cache data. - # If it's empty, the cache data will be stored in $HOME/.cache/actcache. + # 存储缓存数据的目录 + # 如果为空,缓存数据将存储在 $HOME/.cache/actcache dir: "" - # The host of the cache server. - # It's not for the address to listen, but the address to connect from job containers. - # So 0.0.0.0 is a bad choice, leave it empty to detect automatically. + # 缓存服务器的主机地址 + # 这不是监听地址,而是作业容器连接的地址 + # 因此 0.0.0.0 是个不好的选择,留空以自动检测 host: "" - # The port of the cache server. - # 0 means to use a random available port. + # 缓存服务器的端口 + # 0 表示使用随机可用端口 port: 0 - # The external cache server URL. Valid only when enable is true. - # If it's specified, act_runner will use this URL as the ACTIONS_CACHE_URL rather than start a server by itself. - # The URL should generally end with "/". + # 外部缓存服务器 URL。仅在 enable 为 true 时有效 + # 如果指定,act_runner 将使用此 URL 作为 ACTIONS_CACHE_URL 而不是自行启动服务器 + # URL 通常应以 "/" 结尾 external_server: "" container: - # Specifies the network to which the container will connect. - # Could be host, bridge or the name of a custom network. - # If it's empty, act_runner will create a network automatically. + # 指定容器将连接到的网络 + # 可以是 host、bridge 或自定义网络名称 + # 如果为空,act_runner 将自动创建网络 network: "" - # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). + # 启动任务容器时是否使用特权模式(Docker-in-Docker 需要特权模式) privileged: false - # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). + # 启动容器时使用的其他选项(例如 --add-host=my.gitea.url:host-gateway) options: - # The parent directory of a job's working directory. - # NOTE: There is no need to add the first '/' of the path as act_runner will add it automatically. - # If the path starts with '/', the '/' will be trimmed. - # For example, if the parent directory is /path/to/my/dir, workdir_parent should be path/to/my/dir - # If it's empty, /workspace will be used. + # 作业工作目录的父目录 + # 注意:不需要在路径开头添加 '/',act_runner 会自动添加 + # 如果路径以 '/' 开头,'/' 将被修剪 + # 例如,如果父目录是 /path/to/my/dir,workdir_parent 应该是 path/to/my/dir + # 如果为空,将使用 /workspace workdir_parent: - # Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob - # You can specify multiple volumes. If the sequence is empty, no volumes can be mounted. - # For example, if you only allow containers to mount the `data` volume and all the json files in `/src`, you should change the config to: + # 可以挂载到容器的卷(包括绑定挂载)。支持 glob 语法 + # 您可以指定多个卷。如果序列为空,则不能挂载任何卷 + # 例如,如果只允许容器挂载 `data` 卷和 /src 中的所有 json 文件,配置应为: # valid_volumes: # - data # - /src/*.json - # If you want to allow any volume, please use the following configuration: + # 如果要允许任何卷,请使用以下配置: # valid_volumes: # - '**' valid_volumes: [] - # overrides the docker client host with the specified one. - # If it's empty, act_runner will find an available docker host automatically. - # If it's "-", act_runner will find an available docker host automatically, but the docker host won't be mounted to the job containers and service containers. - # If it's not empty or "-", the specified docker host will be used. An error will be returned if it doesn't work. + # 使用指定的 docker 客户端主机覆盖默认值 + # 如果为空,act_runner 将自动查找可用的 docker 主机 + # 如果是 "-",act_runner 将自动查找可用的 docker 主机,但 docker 主机不会挂载到作业容器和服务容器 + # 如果不为空也不是 "-",将使用指定的 docker 主机。如果不起作用将返回错误 docker_host: "" - # Pull docker image(s) even if already present + # 即使已存在也拉取 docker 镜像 force_pull: true - # Rebuild docker image(s) even if already present + # 即使已存在也重新构建 docker 镜像 force_rebuild: false - # Always require a reachable docker daemon, even if not required by act_runner + # 始终要求可访问的 docker 守护进程,即使 act_runner 不需要 require_docker: false - # Timeout to wait for the docker daemon to be reachable, if docker is required by require_docker or act_runner + # 如果 docker 被 require_docker 或 act_runner 需要,等待 docker 守护进程可访问的超时时间 docker_timeout: 0s host: - # The parent directory of a job's working directory. - # If it's empty, $HOME/.cache/act/ will be used. - workdir_parent: + # 作业工作目录的父目录 + # 如果为空,将使用 $HOME/.cache/act/ + workdir_parent: \ No newline at end of file