Gitea Runner
约 4 分钟阅读
标签:Runner
- gitea/act_runner
- 基于 act笔记actnektos/act · MIT, Golang · 本地运行 Github Action · , · 每行一个 flag · --artifact-server-path /tmp/artifacts · -s GITHUBTOKEN= · /.cache/actcache打开:/notes/service/forge/act
- 类似 github action
- hub.docker.com/r/gitea/act_runner/tags
/root/.cache/act/- 参考
- 手动触发 #23668GitHub Issuego-gitea/gitea#23668
- concurrency #24769GitHub Issuego-gitea/gitea#24769
- cron gitea#22751GitHub PRgo-gitea/gitea#22751
- 变量而不是密钥 #23763GitHub Issuego-gitea/gitea#23763
- 日志清理 #24256GitHub Issuego-gitea/gitea#24256
- 基于 Job 的 Token #23642GitHub Issuego-gitea/gitea#23642
docker login -u ${{github.repository_owner}} -p $GITEA_TOKEN- github.actor
- 外部 #24454GitHub Issuego-gitea/gitea#24454
配置 Gitea
[actions]
ENABLED=truehttps://gitea.example.com/admin/runners获取 Token
docker run --rm -it --entrypoint bash gitea/act_runner:nightly
act_runner generate-config > config.yaml
./act_runner register --instance http://192.168.8.8:3000 --token $TOKEN --no-interactive
docker run --rm -it \
-e GITEA_INSTANCE_URL=http://192.168.8.18:3000 \
-e GITEA_RUNNER_REGISTRATION_TOKEN=$TOKEN \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/data:/data \
--name my_runner gitea/act_runner:nightly- 默认缓存位置 ~/.cache/actcache/
log:
# The level of logging, can be 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.
timeout: 3h
# Whether skip verifying the TLS certificate of the Gitea instance.
insecure: false
# The timeout for fetching the job from the Gitea instance.
fetch_timeout: 5s
# The interval for fetching the job from the Gitea instance.
fetch_interval: 2s
cache:
# Enable cache server to use 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.
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.
host: ''
# The port of the cache server.
# 0 means to use a random available port.
port: 0
container:
# Which network to use for the job containers. Could be bridge, host, none, or the name of a custom network.
network_mode: bridge
# Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
privileged: false
# And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
options:
# The parent directory of a job's working directory.
# If it's empty, /workspace will be used.
workdir_parent:cache
Docker
- /root/.cache/act
默认 entrypoint
#!/usr/bin/env bash
if [[ ! -d /data ]]; then
mkdir -p /data
fi
cd /data
CONFIG_ARG=""
if [[ ! -z "${CONFIG_FILE}" ]]; then
CONFIG_ARG="--config ${CONFIG_FILE}"
fi
# Use the same ENV variable names as https://github.com/vegardit/docker-gitea-act-runner
if [[ ! -s .runner ]]; then
try=$((try + 1))
success=0
# The point of this loop is to make it simple, when running both act_runner and gitea in docker,
# for the act_runner to wait a moment for gitea to become available before erroring out. Within
# the context of a single docker-compose, something similar could be done via healthchecks, but
# this is more flexible.
while [[ $success -eq 0 ]] && [[ $try -lt ${GITEA_MAX_REG_ATTEMPTS:-10} ]]; do
act_runner register \
--instance "${GITEA_INSTANCE_URL}" \
--token "${GITEA_RUNNER_REGISTRATION_TOKEN}" \
--name "${GITEA_RUNNER_NAME:-$(hostname)}" \
--labels "${GITEA_RUNNER_LABELS}" \
${CONFIG_ARG} --no-interactive > /tmp/reg.log 2>&1
cat /tmp/reg.log
cat /tmp/reg.log | grep 'Runner registered successfully' > /dev/null
if [[ $? -eq 0 ]]; then
echo "SUCCESS"
success=1
else
echo "Waiting to retry ..."
sleep 5
fi
done
fi
# Prevent reading the token from the act_runner process
unset GITEA_RUNNER_REGISTRATION_TOKEN
act_runner daemon ${CONFIG_ARG}{
"WARNING": "This file is automatically generated by act-runner. Do not edit it manually unless you know what you are doing. Removing this file will cause act runner to re-register as a new runner.",
"id": 1,
"uuid": "",
"name": "gitea-runner-0",
"token": "",
"address": "http://gitea",
"labels": [
"ubuntu-latest:docker://node:16-bullseye",
"ubuntu-22.04:docker://node:16-bullseye",
"ubuntu-20.04:docker://node:16-bullseye",
"ubuntu-18.04:docker://node:16-buster"
]
}GITEA_RUNNER_LABELS=ubuntu-latest:docker://node:16-bullseye,ubuntu-22.04:docker://node:16-bullseye,ubuntu-20.04:docker://node:16-bullseye,ubuntu-18.04:docker://node:16-busterGITEA_RUNNER_LABELS=ubuntu-latest:docker://wener/node:18,alpine-latest:docker://wener/node:18,alpine-exec:hostcloning https://gitea.com/actions/setup-node to /root/.cache/act/actions-setup-node@v3关联信息
反向链接、本文链接的其他页面和外部资料。
反向链接
- Gitea Action笔记 · Runner
参考 · Github Action · Runner · vs Github Action · Mirror · https://github.com/actions/checkout · https://gitea.com/actions/checkout
站内链接
- act笔记 · act
nektos/act · MIT, Golang · 本地运行 Github Action · , · 每行一个 flag · --artifact-server-path /tmp/artifacts · -s GITHUBTOKEN= · /.cache/actcache
参考资料
GitHub9 条
- go-gitea/gitea#22751github.com/go-gitea/gitea/pull/22751
- go-gitea/gitea#23642github.com/go-gitea/gitea/issues/23642
- go-gitea/gitea#23668github.com/go-gitea/gitea/issues/23668
- go-gitea/gitea#23763github.com/go-gitea/gitea/issues/23763
- go-gitea/gitea#24256github.com/go-gitea/gitea/issues/24256
- go-gitea/gitea#24454github.com/go-gitea/gitea/issues/24454
- go-gitea/gitea#24769github.com/go-gitea/gitea/issues/24769
- nektos/act/IMAGES.mdgithub.com/nektos/act/blob/master/IMAGES.md
- vegardit/docker-gitea-act-runnergithub.com/vegardit/docker-gitea-act-runner
其他外链6 条
- dl.gitea.com/act_runnerdl.gitea.com/act_runner
- docs.gitea.com/next/usage/actions/act-runnerdocs.gitea.com/next/usage/actions/act-runner
- docs.gitea.io/en-us/usage/usage/actions/act-runnerdocs.gitea.io/en-us/usage/usage/actions/act-runner
- gitea.com/actionsgitea.com/actions
- gitea.com/gitea/act_runnergitea.com/gitea/act_runner
- hub.docker.com/r/gitea/act_runner/tagshub.docker.com/r/gitea/act_runner/tags