说明
关于GiteaRunner配置相关的文档请参考官方文档:Act Runner | Gitea Documentation
配置
首先编辑Runner的配置文件config.yaml,主要需要编辑的内容如下:
runner:
...
# Github加速镜像站
github_mirror: 'https://gh-proxy.net/https://github.com'
# 构建容器使用国内镜像加速
labels:
- "ubuntu-latest:docker://docker.1ms.run/gitea/runner-images:ubuntu-latest"
- "ubuntu-22.04:docker://docker.1ms.run/gitea/runner-images:ubuntu-24.04"
- "ubuntu-22.04:docker://docker.1ms.run/gitea/runner-images:ubuntu-22.04"
- "ubuntu-20.04:docker://docker.1ms.run/gitea/runner-images:ubuntu-20.04"
cache:
...
# 开启构建 actions 的缓存
enabled: true
container:
...
# 配置构建容器允许挂着的目录
valid_volumes:
- /volume3/docker/service/data/gitea-runner/volumes/distribution
- /volume3/docker/service/data/gitea-runner/volumes/.android
- /volume3/docker/service/data/gitea-runner/volumes/.gradle
- /volume3/docker/service/data/gitea-runner/volumes/.m2
github_mirror
如果你没有此配置或配置后并没有生效,请更新你的Runner到最新:
#716 - feat: support github mirror - act_runner - Gitea: Git with a cup of tea
valid_volumes
# Volumes (including bind mounts) can be mounted to containers. Glob syntax is supported, see https://github.com/gobwas/glob
# You can specify multiple volumes. If the sequence is empty, no volumes can be mounted.
# For example, if you only allow containers to mount the `data` volume and all the json files in `/src`, you should change the config to:
# valid_volumes:
# - data
# - /src/*.json
# If you want to allow any volume, please use the following configuration:
# valid_volumes:
# - '**'
以上是它的官方解释,使用人话大致可以理解为:构建容器中允许挂载的路径。
#226 - Add ValidVolumes config - act_runner - Gitea: Git with a cup of tea
构建
看一下我这里的android.yaml是如何使用的:
name: Android CI
jobs:
build:
name: 构建 Android APK
runs-on: ubuntu-latest
container:
volumes:
- /volume3/docker/service/data/gitea-runner/volumes/distribution:/opt/distribution:ro
- /volume3/docker/service/data/gitea-runner/volumes/.android:/root/.android
- /volume3/docker/service/data/gitea-runner/volumes/.gradle:/root/.gradle
- /volume3/docker/service/data/gitea-runner/volumes/.m2:/root/.m2
env:
ANDROID_HOME: /root/.android/sdk
steps:
- name: 检出代码
uses: actions/checkout@v3
with:
lfs: true
- name: 设置 JDK 21
uses: actions/setup-java@v5
with:
java-version: '21'
distribution: 'jdkfile'
jdkFile: /opt/distribution/OpenJDK21U-jdk_x64_linux_hotspot_21.0.9_10.tar.gz
cache: gradle
- name: 授予 Gradle 执行权限
run: chmod +x ./gradlew
- name: 构建 Release APK
run: >
./gradlew assembleRelease
-Pandroid.injected.signing.key.password=${{ secrets.SIGNING_KEY_PASSWORD }}
env:
SIGNING_KEY_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }}
- name: 上传 Release APK
uses: actions/upload-artifact@v3
with:
name: ApplicationDemo-Release
path: app/build/outputs/apk/release
使用
如果你能看的懂,那么你就可以构建了。要是看不懂,多看看其他文档吧。