# Try Gitea Action


&gt;   我所期待的Gitea action来了但是又没有完全来，怎么说呢，现在gitea支持action的功能还处于pr状态，还没有合并到gitea的main分支。下来我分享一下gitea的action简单上手。

**要求：已经安装1.18以上的go，nodejs LTS等必须条件，并正确配置环境**

## [下载并编译支持gitea action的pr的源代码](https://github.com/go-gitea/gitea/pull/21937)

1.   下载gitea源代码

     ```shell
     git clone https://github.com/go-gitea/gitea
     git branch -r --list
     #  origin/HEAD -&gt; origin/main
     #  origin/backport/21619-v1.17
     #  origin/backport/21619-v1.18
     #  origin/backport/21639-v1.18
     #  origin/backport/21720-v1.17
     #  origin/backport/21720-v1.18
     #  origin/backport/21731-v1.17
     #  origin/backport/21731-v1.18
     #  origin/backport/21830-v1.18
     #  origin/backport/21831-v1.18
     #  origin/bugfix/api_delete_issue
     #  origin/bugfix/fix_never_signed_in
     #  origin/bugfix/fix_reach_limit_of_creation
     #  origin/bugfix/hook_config_file
     #  origin/bugfix/ignore_config_template
     #  origin/bugfix/markdown_template_without_metadata
     #  origin/bugfix/single_label_in_template
     #  origin/feature/add_dockerignore
     #  origin/feature/bots
     #  origin/feature/drop_yaml_v2
     #  origin/feature/index_token_last_eight
     #  origin/feature/refactor_update_session
     #  origin/feature/test_primary_keys
     #  origin/main
     #  origin/release/v1.17
     #  origin/release/v1.18
     git checkout feature/bots
     ```

     

2.   编译gitea

     ```shell
     TAGS=&#34;bindata&#34; make build
     ```

3.   启动gitea实例

     ```shell
     ./gitea web
     ```

 4.    gitea安装过程省略

 5.    下载gitea act-runner源码

       ```shell
       git clone https://gitea.com/gitea/act_runner.git
       ```

6.   编译gitea act-runner

     ```shell
     make build
     ```

7.   获取REGISTRATION TOKEN

​	仓库设置-&gt;repo.settings.runners-&gt;Create new runner-&gt;copy REGISTRATION TOKEN

​	![image](https://img.nil.lc/img/202211262135021.png)

 8.    注册runner

       ```shell
       ./act_runner register --instance gitea app.ini配置文件的[server]ROOT_URL的值 --token 第7步复制的REGISTRATION TOKEN --no-interactive
       ```

9.   启动runner

     ```shell
     sudo ./act_runner daemon
     ```

10.   修改runner的labels为：`ubuntu-latest`这个`label`要和下面的`hello.yml`中的`runs-on`一致

11.   在刚才的仓库下创建workflow的描述文件

      ```shell
      mkdir -p .gitea/workflows/
      vim .gitea/workflows/hello.yml # 这里的文件名可以随意取，但是拓展名必须为yml或者yaml
      # 输入以下测试内容：
      ```

      ```yml
      name: Hello Gitea
      on: [push]
      jobs:
          job:
              name: hello
              runs-on: ubuntu-latest
              steps:
                  - run: echo &#39;Hello Gitea Runner!&#39;
      ```

      

效果展示：

![image-20221126214822538](https://img.nil.lc/img/202211262148845.png)

### Enjoy it！

**References：**

-   https://github.com/go-gitea/gitea

-   https://gitea.com/gitea/act_runner.git


---

> 作者: hiifong  
> URL: https://f.style/try-gitea-action/  

