Try Gitea Action

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

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

下载并编译支持gitea action的pr的源代码

  1. 下载gitea源代码

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    
    git clone https://github.com/go-gitea/gitea
    git branch -r --list
    #  origin/HEAD -> 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

    1
    
    TAGS="bindata" make build
    
  3. 启动gitea实例

    1
    
    ./gitea web
    
  4. gitea安装过程省略

  5. 下载gitea act-runner源码

    1
    
    git clone https://gitea.com/gitea/act_runner.git
    
  6. 编译gitea act-runner

    1
    
    make build
    
  7. 获取REGISTRATION TOKEN

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

image

  1. 注册runner

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

    1
    
    sudo ./act_runner daemon
    
  3. 修改runner的labels为:ubuntu-latest这个label要和下面的hello.yml中的runs-on一致

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

    1
    2
    3
    
    mkdir -p .gitea/workflows/
    vim .gitea/workflows/hello.yml # 这里的文件名可以随意取,但是拓展名必须为yml或者yaml
    # 输入以下测试内容:
    
    1
    2
    3
    4
    5
    6
    7
    8
    
    name: Hello Gitea
    on: [push]
    jobs:
        job:
            name: hello
            runs-on: ubuntu-latest
            steps:
                - run: echo 'Hello Gitea Runner!'
    

效果展示:

image-20221126214822538

Enjoy it!

References:

Buy Me a Coffee ~~
hiifong 支付宝 支付宝
hiifong 微信 微信
hiifong 赞赏码 赞赏码
0%