如何使我自己托管的GitHub运行器在docker容器中运行作业,而不是本机shell和操作系统? &



我注册了我的Raspberry Pi 4作为GitHub的自托管运行器。它可以工作,但所有作业都在本机系统本身上运行。我怎样才能使GitHub也创建一个Docker容器上的跑步者,使底层系统保持干净?这是gilab的默认行为,我很惊讶它不适合GiHub,或者我可能错过了一些东西,请帮助我。

# This is a basic workflow to help you get started with Actions
name: CI Rasp
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
# Runs a set of commands using the runners shell
- name: Run blinky for 3 times
run: /home/jbron/blinky.py

我正在尝试使用container上下文实现相同的目标。

我想应该是这样的:

# This is a basic workflow to help you get started with Actions
name: CI Rasp
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: self-hosted
container:
# Runner docker image
image: ubuntu:22.04
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Runs a single command using the runners shell
- name: Run a one-line script
run: echo Hello, world!
# Runs a set of commands using the runners shell
- name: Run blinky for 3 times
run: /home/jbron/blinky.py

点击此链接获取更多信息:

https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions jobsjob_idcontainer

相关内容

  • 没有找到相关文章

最新更新