在 github 操作中开始服务之前克​​隆数据

Clone data befor starting service in github actions

我尝试构建一个 git 集线器操作工作流,该工作流依赖于数据库(可用作 docker 容器),而数据库又依赖于需要从 git 存储库。 启动 docker 容器时数据需要可用。

目前我有以下设置 (the complete file is available on 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
        …

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

我发现,我可以定义一个 运行 是 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
      - …

实际完整的文件是available on GitHub

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