Search code examples
workflowartifactsgithub-actions

Github action not uploading artifact


I'm having an issue with uploading artifacts to github from within a workflow.

This is my yaml file:


on:
  push:
      branches:
      - master

jobs:
    build:
      name: build and test
      runs-on: ubuntu-latest

      steps:
        - uses: actions/checkout@v1
        - name: Install robotframework and dependencies
          run: |
            pip install selenium
            pip install robotframework
            pip install robotframework-seleniumlibrary
            pip install robotframework-imaplibrary
            pip install robotframework-httplibrary
            pip install robotframework-requests
        - name: Download and install chromedriver
          run: |
            wget http://chromedriver.storage.googleapis.com/77.0.3865.10/chromedriver_linux64.zip
            sudo unzip chromedriver_linux64.zip -d /usr/local/bin
            export CHROME_BIN=chromium-browser
        - name: Run robot tests
          run: |
            cd robot/tests
            python -m robot -i ready bookingform.robot
        - name: publish test results
          uses: actions/upload-artifact@v1
          with:
            name: report
            path: report.html
        - name: clean up stuff
          run: |
            history
            pwd

Everything runs fine up until "publish test results", at which point nothing is written to the logs and no artifacts are uploaded. If I view the workflow log, there is a grey icon alongside that step (not the usual check or red x), so I'm really baffled at what could be happening. I added arbitrary stuff to the "clean up stuff" step just to test what happens, and that step isn't run either.

I've tried messing around with the path, thinking that it could be related to the path being invalid or something, but that hasn't helped. No matter what I add near the bottom of that file, the same behaviour occurs.

I have tried running another workflow file which uploads artifacts and that ran fine, the logs showed that the upload action was invoked and that the artifact was saved, but I don't see anything like that when my yaml file is used.


Solution

  • Each job step resets the working path to GITHUB_WORKSPACE, which will be the root of your repository after actions/checkout runs.

    The upload-artifact action most likely can't find report.html because it's no longer in the correct directory.

    Try changing the path as follows:

            - name: publish test results
              uses: actions/upload-artifact@v1
              with:
                name: report
                path: robot/tests/report.html
    

    There is also a working-directory that you can set for a step. However, it seems to be incompatible with uses for actions. It can only apply to run script steps.

    Using working-directory with uses will NOT work:

            - name: publish test results
              working-directory: robot/tests
              uses: actions/upload-artifact@v1
              with:
                name: report
                path: report.html
    

    Using working-directory with run will work:

            - name: print test results
              working-directory: robot/tests
              run: cat report.html