Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run a docker container with GitHub actions?

I'm want to perform CI with tests that depends on a container that is published in Docker Hub. Is it possible? Can I start the container and run tests that depends on it?

like image 921
Bruno Brant Avatar asked Dec 19 '19 15:12

Bruno Brant


People also ask

Does GitHub Action Use containers?

GitHub Actions allows you to run a job within a container, using the container: statement in your workflow file. For more information, see "Running jobs in a container." To process container-based jobs, the self-hosted runner creates a container for each job.

Can I host a Docker image on GitHub?

You can publish Docker images to a registry, such as Docker Hub or GitHub Packages, as part of your continuous integration (CI) workflow.


1 Answers

Yes, here is an example using docker-compose:

  test:
    name: Test
    runs-on: ubuntu-latest
    steps:
      - name: Check out code
        uses: actions/checkout@v1

      - name: Login to Docker Registry
        run: docker login "$DOCKER_REGISTRY" -u "$DOCKER_USERNAME" --password-stdin <<< "$DOCKER_PASSWORD"
        env:
          DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
          DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
          DOCKER_REGISTRY: ${{ secrets.DOCKER_REGISTRY }}
      - name: Start env
        run: docker-compose up
      - name: Run tests
        run: ...
like image 98
scthi Avatar answered Sep 22 '22 15:09

scthi