Clone data befor starting service in github actions

897 views Asked by At

I try to build a github action workflow that depends on a database (available as docker container) which in turn depends on data that needs to be cloned from a git repository. The data needs to be available when starting the docker container.

Currently I rawly have the following setup (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
        …

If it is not possible to clone the repository before starting the service, is it possible to clone the repository and then start the container as one of the steps and keep it in the background?

1

There are 1 answers

0
white_gecko On BEST ANSWER

I found out, that I can just define a step that runs a docker container. Thus I could first execute the checkout action and subsequently run the database:

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
      - …

The actual and complete file is available on GitHub.

This in turn resulted in the problem that I could not reach the database container from any further actions. This issue is covered here: Access a container by hostname in github actions from within an action