Custom docker action mounted volumes

I’m trying to create a docker container action and followed the tutorial here and all went fine. I however want to use that action in a workflow that checkouts multiple repos and the problem i have is that the workspace mounted into the action docker image is the default checkout folder where the workflow exists. For example, i’ve been testing in this repo https://github.com/hbfernandes/actions which leads to the folowing volume being mounted.

-v “/home/runner/work/actions/actions”:"/github/workspace"

Is there a way to change the mounts from the workflow definition or within the action definition? The working directory is not available for “use” actions and i can’t find anything about it in the documentation. I could of course workaround by checking stuff out into the “actions/actions” directory but that seems pretty dirty. 

Edit:

I will elaborate a bit more on the example so it becomes clearer.

I have a repo where i want to add a workflow to orchestrate a build of several projects in different repos. For this i’ll refer to it as workflow-repo.  From a workflow in this repo i want to checkout project _ A _, _ B _ and _ C. _ After checking them out i want to run a custom docker container action that for the sake of simplicity is also in the _ workflow-repo.  _This would look something like this:

jobs:
  build:
    runs-on: ubuntu-latest
    name: Multiple repo work
    steps:
    - name: Checkout current repo
      uses: actions/checkout@v1

    - name: Checkout repo A
      uses: actions/checkout@v1
      with:
        repository: org/a
        ref: master

    - name: Checkout repo B
      uses: actions/checkout@v1
      with:
        repository: org/b
        ref: master

    - name: Checkout repo C
      uses: actions/checkout@v1
      with:
        repository: org/c
        ref: master

    - name: Run Custom Docker Action
      uses: ./maven # local action
      with:
        args: clean

with this the checkouts would be performed on the these paths:

/home/runner/work/workflow-repo/workflow-repo  
/home/runner/work/workflow-repo/a  
/home/runner/work/workflow-repo/b  
/home/runner/work/workflow-repo/c

My issue is that when running the Docker action the workspace is mounted as a volume to the container using the first or these, the default checkout path.

-v "/home/runner/work/workflow-repo/workflow-repo":"/github/workspace"

This way i cannot reach the other checkouts from within the container. My question is if there is any way to control this mount.

2 Likes

Hi @hbfernandes ,

Do you mean you want to use checkout action to check out your Docker container actions into the _actions folder under the runner working directory?
If so, I’m afraid you are not able to do this. The checkout action seems only supports to check out the resource files into the source directory of current repository where the workflow is in, not outside of the source directory.
However, as a workaround, you can directly use the actions in the workflow, and in this way, the resource files of the used actions will be automatically downloaded into the _actions folder under the runner working directory.

- uses: pentaho/maven-parent-poms@master

Hey @brightran 

Thanks for your reply, however that is not the scenario meant to refer to. I’ve edited the main post with more info and a more in depth example that hopefully makes it clearer on what i’m trying to achieve.

Hi @hbfernandes - to change the entrypoint when running a Docker container use the entrypoint: syntax - see https://help.github.com/en/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstepswithargs

Your Docker contain should be able to access the checked out repos in the VM’s /home  under the /github/home mount in the container. The directories exposed to Docker actions are exposed to allow multiple steps to operate on the same data.

Hi @timruffles 

I’m a bit confused with your answer. I’ve seen the entrypoint part and thats alll fine, my issue is only related to container mounted paths and how best to make use of them. From what i can see from the docker action step we have these:

-v "/home/runner/work/_temp/_github_home":"/github/home"
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow"
-v "/home/runner/work/workflow-repo/workflow-repo":"/github/workspace"

Are you suggesting i should place the checked out projects in  “/home/runner/work/_temp/_github_home” to then work them within the container in “/github/home” ?

I want to do similar thing for $HOME/.m2 directory to share locally-built Maven artifacts to my action running as a Docker container. I ended up specifying this somewhat strange directory -Duser.home=/home/runner/work/_temp/_github_home when building the artifacts:

I appreciate if we can find a better solution to share directories to GitHub Action Docker container.