+++ date = "2024-03-04" tags = ["gitea"] title = "gitea actionsに移行するかも" slug = "gitea" +++ `gitea actions`というのは、`github actions`とか`gitlab-ci`と呼ばれるものに相当するものなんだけど、有効にするかどうか迷っていました。 というのもserverの負担が増大するし、いくつものserviceを動作させている環境だと、それぞれの反応がどうしても遅くなってしまうからです。 したがって、こういうのは全部無料で使えるgithubを利用するのが一番でした。 しかし、最近になってusername(id)の関係でgiteaを使う頻度が増えてきたので、`gitea actions`を有効にすることにしました。 githubでは使いたいusername(id)がすでに取られていることが多く、時代はself-hostやdomainになっていくのだろうなあと、そんなふうに思います。 私の場合、最近になってreposを整理したこともあり、ネームスペースは結構気になります。 例えば、最近作った自作osは`ai os`という名前ですが、`username/aios`ではなく、`ai/os`というネームスペースを使用したかった。 - o `git@git.syui.ai:ai/os.git` - x `git@github.com:username/aios.git` とはいえ、これもちょっと分かりづらいですよね。本来は`ai/aios`とかのほうがわかりやすいかな。まあ、好みの問題ということにしておきましょう。 ## gitea actionsの構築 `gitea ci`とも呼ばれます。 https://blog.gitea.com/hacking-on-gitea-actions/ ```sh:/app/data/gitea/conf/app.ini [actions] ENABLED=true ``` web-uiでsettingからactionsのtokenを取得しておいてください。 ```sh $ git clone https://gitea.com/gitea/act_runner $ cd act_runner $ make build $ ./act_runner register $ ./act_runner daemon # nohup ./act_runner daemon & ``` これで使えるはず。statusがアイドルになります。 ![](/img/gitea-ci_0001.png) あとはgh-actionsと同じようにrepoに設定ファイルを置いて`push`します。 ```yml:.gitea/workflows/demo.yaml name: Gitea Actions Demo run-name: ${{ gitea.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 ${{ 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 uses: actions/checkout@v3 - 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 run: | ls ${{ gitea.workspace }} - run: echo "🍏 This job's status is ${{ gitea.status }}." ``` ## docker images(container registry) docker imagesの置き場所としてdocker hub(dockerhub)が最も支配的で、かつ使いやすいです。 なぜなら、デフォルトでdockerhubが指定されるからです。 ただ、`github packages(ghcr.io)`に置いてあることも増えてきて、`github actions`の影響が大きいと思います。 ```sh $ docker run -it syui/aios ai $ docker run -it ghcr.io/syui/aios ai ``` しかし、今まで`syui/aios`を使っていましたが、`gitea actions`を有効にしたことで`ai/os`に置き換えやすくなります。というか、有効にしたのは、主にこれのためです。 ```sh $ docker tag syui/aios git.syui.ai/ai/os $ docker push git.syui.ai/ai/os ``` ```sh $ docker run -it git.syui.ai/ai/os ai ``` ただ、docker imagesは本当に容量を食うので、あまりおすすめできない。dockerhubに置くのが一番でしょう。 私の場合、repoをgiteaに移行したのに、dockerだけgithub, dockerhubなのはあまり良くない。ネームスペースが異なるのが良くない。dockerもgiteaに移行するかも。 なんか2GBを超えたあたりでpushできなくなります。 > received unexpected HTTP status: 500 Internal Server Error ```sh The push refers to repository [***/divya.jain/homer] 994393dc58e7: Pushed received unexpected HTTP status: 500 Internal Server Error ``` - https://github.com/go-gitea/gitea/issues/21320 したがって、localhostからpushします。 ## actions runner - https://docs.gitea.com/usage/actions/act-runner#labels - https://forum.gitea.com/t/gitea-actions-cannot-find-node-in-path/7544/6 > OCI runtime exec failed: exec failed: unable to start container process: exec: "node": executable file not found in $PATH: unknown nodeをdocker(gitea-runner)にinstallしてもcheckoutのときにerrが出ます。 ただ、`runs-on: ubuntu-latest`のみならerrがでません。したがって、これは`container: archlinux`が問題なのかもしれません。 どちらにせよarchisoはarchlinuxで実行しますので、nodeをinstallした`container: syui/aios`を使用します。 ```yaml runs-on: ubuntu-latest container: #image: archlinux image: syui/aios ```