6

I have the following logic in my Github Actions:

  1. Checkout a different repository
  2. Inside that repository run docker command
  3. Checkout my current repository of the workflow
  4. Run code on the running docker instance

However, when I do this, I see that a local folder from step 1 was not mounted to docker container.

I want to mount a local directory as a volume to a docker container. Here is how my docker-compose file looks like:

version: '3.9'

services:
  kong-cp:
    image: myImage
    restart: on-failure
    user: root
    volumes:
      - ./rsa:/tmp

Here is what my GitHub Actions workflow looks like:

name: Test

on: workflow_dispatch

jobs:
  tests:
    runs-on: ubuntu-latest

    steps:  
      - name: Checkout docker-compose-generator
        uses: actions/checkout@v3
        with:
          repository: docker-compose-generator
          token: ${{ secrets.GH_TOKEN }}
          ref: test/mount

      - name: Login to Docker Hub
        uses: docker/login-action@v1
        with:
          username: ${{ secrets.DOCKERHUB_USR }}
          password: ${{ secrets.DOCKERHUB_PSW }}

      - name: Start Docker
        run: docker-compose up -d

      - name: Checkout
        uses: actions/checkout@v3

      - name: Run my Code
        run: npm run test

The rsa folder contains 2 files. After starting docker I see that the target tmp directory in container is empty. When I do the same on my local machine or in AWS EC2 instance, everything works correct. When I run the same docker-compose command on its own repository/workflow (docker-compose-generator) everything works correct and I see the mounted directory.

I think this is related to docker permissions where it fails to mount directories which belong to different checked out repsoitory.

Does anyone know what can be the issue here?

Hayk
  • 441
  • 1
  • 4
  • 7

0 Answers0