The upcoming Gitea Actions is committed to creating a standard protocol for CI/CD tools. Third-party CI systems can integrate with the Gitea platform based on the actions protocol to provide a one-stop management solution. Gitea Actions has taken the first step towards this.

Learn GitHub Actions

GitHub Actions is a continuous integration and continuous delivery (CI/CD) platform that can be used to automate tasks, testing, and deployment. Users can create workflows to build and test each pull request for a repository, or deploy merged pull requests to production.

GitHub Actions is more than just DevOps, allowing users to run workflows when other events happen in the repository. For example, you can run a workflow that automatically adds appropriate tags when someone creates a new issue.

GitHub offers Linux, Windows, and macOS virtual machines to run workflows, or host runners in its own data centers or cloud infrastructure.

Gitea’s DevOps ecosystem

Thanks to the support of the vast open source community, Gitea can now be well adapted to the following DevOps tools.

  • Agola
  • App Veyor
  • AWS Cloud Integration (webhook-to-s3)
  • buildbot-gitea
  • buildkite-connector
  • Concourse
  • Dex
  • Drone
  • Ghorg
  • gickup
  • Jenkins
  • Jianmu CI
  • Metroline
  • Monitoring mixins
  • wxya
  • Renovate
  • Tea Runner
  • Woodpecker

After long-term community interaction, we have obtained a large number of third-party CI system integration solutions. However, we have always found that independently building and operating a complete set of CI systems is only the expertise of a small number of geeks. For a wider range of users, this is not an easy task, so we began to try to work hard for this and make the tools better. serve people.

Build Gitea Actions

It is undeniable that GitHub Actions has created a great working environment. Its design concept enables closer integration between warehouses and CI tools, realizing code as configuration, and platform users provide rich application extensions for the entire system. , Compared with the traditional mode, it is better in ease of use. It would be great to port its benefits to Gitea.

The good news is that after two years of research and discussion, we have finally put the development task of Gitea’s built-in CI/CD system on the agenda. (#13539)

development progress

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

Gitea Actions implements a built-in CI/CD system framework, compatible with GitHub Actions’ YAML workflow orchestration format, and compatible with most existing Actions plugins in GitHub Marketplace.

The system consists of three parts:

  • Definition of the Gitea Actions protocol and Golang implementation
  • Actions Runner: based on nektos/act Implemented Task Subsystem
  • Implement the Runner task management and scheduling module on the Gitea main program

run screenshot

1. The system administrator can access the Runners management interface to create, edit and delete Runners.

Runners management interface

2. Open Actions through the navigation at the top of the warehouse to view CI build information.

Workflows list under warehouse

3. Click a CI build result to view the log.

Click Workflows to view the execution log

early adopters experience

⚠ Experimental function, do not use in production environment

prepare the environment

  • Memory: at least 4GB, for compiling Gitea
  • Docker: executable docker command for pulling and running containers

to build

1. Compile and run Gitea

Download Gitea source code with Actions module:


# 目前可以从 @wolfogre 的开发分支克隆带有 Actions 模块的源代码到本地编译。
git clone https://github.com/wolfogre/gitea.git --branch=feature/bots
cd gitea

Compilation method can refer to install from source code. Here we need to prepare the development environment Node.js LTS (nvm instal --lts) and Golang.

The following is the recommended packaging method (with SQLite for local testing)


TAGS="bindata sqlite sqlite_unlock_notify" make build

Start the Gitea main program.Here, the initialization steps are completed first, and a configuration file will be generated, which is located in the current directory.


./custom/conf/app.ini

Edit the above configuration file and open the Actions function.


[actions]
ENABLED = true

Restart the program:./gitea web

2. Start the Runner

compile first act_runner program


git clone https://gitea.com/gitea/act_runner.git
cd act_runner
make build

Then register the Runner with the Gitea server.

  • Method 1: Use interactive commands to configure

$ ./act_runner register

INFO Registering runner, arch=amd64, os=linux, version=0.1.5.
WARN Runner in user-mode.
INFO Enter the Gitea instance URL (for example, https://gitea.com/): [输入服务器地址]
INFO Enter the runner token: [输入 Runner 令牌]
INFO Enter the runner name (if set empty, use hostname:ubuntu ): [输入 Runner 名称]
INFO Enter the runner labels, leave blank to use the default labels (comma-separated, for example, ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-buster): [输入 Runner 标签]

...
DEBU Successfully pinged the Gitea instance server
INFO Runner registered successfully.
  • Method 2: Non-interactive commands
    • --no-interactive
    • --instance Fill in the server address
    • --token Fill in the Actions token (/admin/runners)

./act_runner register --instance http:// --token  --no-interactive

starting program


./act_runner daemon

3. Enable the Actions function for the warehouse

You can create a new warehouse and manually enable the Actions function in the warehouse settings.

Enable the Actions feature

After refreshing the page, we can find that there is an Actions function in the function navigation bar at the top of the warehouse. Click Actions to enter and you can see the currently empty All Workflows task list.

4. Upload the Workflows configuration to the warehouse directory .gitea/workflows/build.yaml. Since Gitea Actions is compatible with GitHub Actions, you can copy the examples from the GitHub documentation. Start learning to use Gitea Actions!


🚀 阅读文档
https://docs.github.com/en/actions/quickstart

Here is an example, save it to .gitea/workflows/build.yaml A CI job is triggered when:


name: Gitea Actions Demo
run-name: ${{ github.actor }} is testing out Gitea Actions 🚀
on: [push]
jobs:
  Explore-Gitea-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.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 ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "💡 The ${{ github.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
        run: |
          ls ${{ github.workspace }}
      - run: echo "🍏 This job's status is ${{ job.status }}."

At the same time, we navigate to the Actions function panel again, and we can see that the newly created Workflow has been executed and the operation log has been recorded.

5. Check the logs generated during CI execution. It is not difficult to see that Gitea Runner pulls the Docker image as the basic environment required for the CI build process.

6. Learn more about the usage of Actions from the GitHub documentation, and you can suggest improvements for us at the same time!


🤖 Implement actions
https://github.com/go-gitea/gitea/pull/21937

🔧 GitHub Actions
https://docs.github.com/zh/actions/using-workflows

#Experience #Gitea #Actions #News Fast Delivery

Leave a Comment

Your email address will not be published. Required fields are marked *