fdiori
fdiori

Reputation: 101

How to retrieve file from /home/runner/XXXXX in GitHub Actions

I am trying to build maven project with GitHub Actions, and after the job running, I get the message

Please refer to /home/runner/work/testDemoAPI/testDemoAPI/mymeeave/target/surefire-reports for the individual test results.

Do you know how to retrieve data from /home/runner/work/xxxxx?

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Maven
      run:  mvn clean test

Upvotes: 10

Views: 11857

Answers (2)

mgibson
mgibson

Reputation: 6223

You can save files to /home/runner and access them in later actions.

An example from my project which:

  • Runs tests

  • Store logs always and test failed file

  • Upload logs as artefact

  • Exits if the test was failure

    - name: Run web E2E tests
      run: |
        set +e
        yarn test-e2e
        result=$?
        if [ $result != 0 ]; then touch /home/runner/test-failed-web-e2e; fi
        kubectl logs $(kubectl get pods | grep backend | awk '{print $1}') > /home/runner/logs-backend.txt
        kubectl logs $(kubectl get pods | grep frontend | awk '{print $1}') > /home/runner/logs-frontend.txt
    
    - name: Upload logs
      uses: actions/upload-artifact@v2
      with:
        name: logs-all
        path: /home/runner/logs-*.txt
        retention-days: 5
    
    - name: Propagate any E2E test failures
      run: |
        if [ -f /home/runner/test-failed-web-e2e ]; then exit 1; fi
    

Upvotes: 1

riQQ
riQQ

Reputation: 12921

Upload it as an artifact, afterwards it can be downloaded from the GitHub UI or via the GitHub API:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Build with Maven
      run:  mvn clean test

    - name: Upload artifact
      uses: actions/upload-artifact@v1
      with:
        name: surefire-reports
        path: mymeeave/target/surefire-reports/**

See https://github.com/actions/upload-artifact for documentation.

Upvotes: 7

Related Questions