2

我尝试构建一个 github 操作工作流,它依赖于数据库(可作为 docker 容器使用),而数据库又依赖于需要从 git 存储库克隆的数据。启动 docker 容器时数据需要可用。

目前我原始有以下设置(完整文件可在 GitHub 上找到

jobs:
  build-and-publish:
    runs-on: ubuntu-latest # This job uses a GitHub-hosted runner.

    services:
      # befor this service is started the repository
      # https://github.com/AKSW/aksw.org-model.git
      # needs to be clones to a volume
      fuseki:
        image: stain/jena-fuseki
        ports:
        - 3030:3030
        volumes:
        - ${{ github.workspace }}/aksw-model:/staging
        options: --entrypoint "exec /jena-fuseki/fuseki-server --file=/staging/aksw.org.nt /aksw"

    steps:
      # Checkout the data repository
      - name: Check out Model Repository
        uses: actions/checkout@v2
        with:
          # Repository name with owner. For example, actions/checkout
          # Default: ${{ github.repository }}
          repository: 'https://github.com/AKSW/aksw.org-model.git'
          path: 'aksw-model'
      - name: Further steps
        …

如果在启动服务之前无法克隆存储库,是否可以克隆存储库,然后将容器作为步骤之一启动并保持在后台?

4

1 回答 1

2

我发现,我可以定义一个运行 docker 容器的步骤。因此,我可以先执行结帐操作,然后运行数据库:

jobs:
  build-and-publish:
    runs-on: ubuntu-latest

    steps:
      - name: Check out Model Repository
        uses: actions/checkout@v2
        with:
          repository: 'AKSW/aksw.org-model'
          path: '.aksw-model'
      - name: Run Triple Store
        run: docker run -v ${{ github.workspace }}/.aksw-model:/staging --name fuseki -d stain/jena-fuseki /jena-fuseki/fuseki-server --file=/staging/aksw.org.nt /aksw
      - …

GitHub 上提供了实际且完整的文件。

这反过来又导致了我无法通过任何进一步的操作访问数据库容器的问题。此处介绍了此问题:Access a container by hostname in github actions from within an action

于 2020-12-17T18:54:39.227 回答