How to access path from Docker image?

Ciao,
after running a lot of tests I’m hoping someone on here has a hint for me.

I am using a docker image for the 3D software Autodesk Maya:

Eventually I need to access Maya’s Python. On Linux machines that’s usually: /usr/autodesk/maya/bin/mayapy

My best guess so far is:

jobs:
  test_maya:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      
    - name: Load Docker Image
      uses: docker://mottosso/maya:2018
      with:
        path: usr/autodesk/maya

But for the love of god I can’t access/find where that image was installed, or how to access mayapy. Can someone help me?

Hopefully I didn’t just make a fool of myself :slight_smile: Started using GitHub’s Actions a couple days ago.

Hi @mischakolbe,

Glad to see you in Github Community Forum!

You can use jobs.<job_id>.steps.with.args to pass the command to the docker image.

To access /user/autodesk/maya folder, please use below format:

    - name: Load Docker Image
      uses: docker://mottosso/maya:2018
      with:
        args: /bin/sh -c "cd /usr/autodesk/maya && ls -la"    # access folder and list the files

My workflow for your reference.

I notice the mayapy is set as the default python, you can simply pass the command to the docker image.

    - name: Load Docker Image
      uses: docker://mottosso/maya:2018
      with:
        args: python -V

Thanks.

1 Like

You absolute legend, @weide-zhou! Thank you so, so much!!

With a couple extra tests this setup is now more streamlined than ever before. If someone told me 1 week ago that this could be all that I need for CI I would have thought they’re nuts:

name: NoCa CI

# Run tests on any push or pullRequest event
on: [push, pull_request]

jobs:
  test_maya:
    runs-on: ubuntu-latest

    steps:
    # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
    - uses: actions/checkout@v2
      
    - name: Load Docker Image
      uses: docker://mottosso/maya:2018
      with:
        args: /usr/autodesk/maya/bin/mayapy -m unittest discover -s ./tests -v

I noticed too, that python is supposed to be an alias for mayapy. I just did a test and that doesn’t seem to be the case though. But accessing the executable directly works great.

Out of curiosity:
Is the uses kind of its own scope? So any command ran outside of it doesn’t have access to - for example - mayapy anymore?

For the very unlikely case someone else needs to test Maya code; this is my latest version.

It’s a bit shabby, because I couldn’t get the uses: docker://mottosso/maya:${{ matrix.version }} to work…
I’ll revisit that again, but at least it works:

name: NoCa CI

# Run tests on any push or pullRequest event
on: [push, pull_request]

jobs:
  maya2017:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    - name: Load Docker Image
      uses: docker://mottosso/maya:2017
      with:
        args: /usr/autodesk/maya/bin/mayapy -m unittest discover -s ./tests -v
         
  maya2018:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    - name: Load Docker Image
      uses: docker://mottosso/maya:2018
      with:
        args: /usr/autodesk/maya/bin/mayapy -m unittest discover -s ./tests -v
         
  maya2019:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    - name: Load Docker Image
      uses: docker://mottosso/maya:2019
      with:
        args: /usr/autodesk/maya/bin/mayapy -m unittest discover -s ./tests -v
         
  maya2020:
    runs-on: ubuntu-latest
    
    steps:
    - uses: actions/checkout@v2
    - name: Load Docker Image
      uses: docker://mottosso/maya:2020
      with:
        args: /usr/autodesk/maya/bin/mayapy -m unittest discover -s ./tests -v
1 Like

Hi @mischakolbe,

Thanks for your reply and Glad to know it works for you!

uses will pull the actions content or image to your runner, in your case, the command run outside of it doesn’t have access to the mayapy command, since it’s only executed in the docker not hosted runner, and after the step completed, the docker has been terminated.

variables are not accepted in the uses:image:tag , you have to use hard code. :slightly_smiling_face:

You can mark your answer as a solution since it’s resolved now.

Thanks

1 Like

I marked my last response as the solution.

I read a few things about variables in uses. I can’t fully wrap my head around the reason why that doesn’t work, but I understand that it’s just not possible :slight_smile:

Thank you so much for all your help, @weide-zhou!

For anyone interested; I wrote a blog post about the pretty straight forward setup I managed to put in place: