Services and Volumes

I have successfully setup two static analysis jobs within my workflow, and I feel like I got all the way up to the final command … But cannot figure out the last bit!

In this particular job I have 4 services all successfully setup, but they cannot seem to connect to the volumes I specified. I am trying to map my repository to the /var/www/ folder inside the container. Here is my workflow, the first two jobs run perfectly but when I try to access the repo files within the container it is empty:

name: CI


  • staging

runs-on: ubuntu-latest
image: php:7.2-fpm

  • 9000
  • $GITHUB_WORKSPACE:/var/www/html
    options: --name opus_app
  • name: Checkout Code
    uses: actions/checkout@v1
    run: |
  • name: Print directory
    run: docker exec opus_app pwd

In case anyone finds this issue, the real issue is that you cannot map volumes to your codebase BEFORE checking out your codebase … so the volumes inside of services is a bit limited to only sharing data between services, where it gets the data from not too sure, but I got around this by using docker-compose to build my services AFTER checking out the code!


I found a workaround for this. I’m using an nginx server to host the build directory generated during the build process. But there are two issues here. First, the volumes options for the services apparently are not working. So I pass a -v parameter with options insted. The second issue is that the service is started before the code is checked out, and that action seems to be re-creating the working directory, but because the service is already running mapped to the old directory it wont see the new content generated there.

My solution then is to start the service with a well known name and then restart it before using it. This is the service declaration:

    image: nginx
    options: -v ${{ github.workspace }}/build:/usr/share/nginx/html --name nginx

And once the content is generated and ready to be served, the container is restarted:

- name: Restart nginx
  uses: docker://docker
    args: docker restart nginx

After that nginx will be serving the generated content just fine!


Thanks for replying! I did end up just replacing it with a complete docker compose file.

I already had a working local dev environment using compose, and didn’t realize that I could just call the same ‘docker-compose up’ inside of actions! Then you can make use of shared volumes using compose options and more advanced networking options.

So I now have a full environment inside my workflow with an empty DB, that starts up 5 containers in about 2 min.

Currently only using it for CI testing but it works fantastic and is super fast.