Home > Software engineering >  GitHub Action errors because it can't see a folder
GitHub Action errors because it can't see a folder

Time:05-05

I'm trying to set up my first GiHub Action. All it needs to do is run a test over my Godot files. I based it on a template.

name: CI

on:
  pull_request:
    branches: [ main ]
  workflow_dispatch:
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: godot-tester
      uses: croconut/[email protected]
      with:
        version: 3.4
        release_type: stable
        # Give relative path to your project.godot, if not in top level of repo
        path: app

The action errors every time, when trying to find the project file.

/entrypoint.sh: line 166: cd: ./app: No such file or directory

A screenshot of the error

The folder, app, is there and it contains the project. I've tried with or without a trailing slash, it makes no difference.

enter image description here The app folder, showing the project file

CodePudding user response:

When you need to access the files from the proper repository in a Github Actions workflow, you need to setup the actions/checkout first.

This will allow the workflow to access the Github workspace (which is basically the repository root).

In your case, the workflow should look like this:

name: CI

on:
  pull_request:
    branches: [ main ]
  workflow_dispatch:
  
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: godot-tester
      uses: croconut/[email protected]
      with:
        version: 3.4
        release_type: stable
        # Give relative path to your project.godot, if not in top level of repo
        path: app

The actions/checkout action has a default behavior, but you can also configure other fields to customize what you want it to do. Check the action README page to see all the possibilities.

  • Related