Search code examples
dockerdockerfilegithub-actionsbuilding-github-actions

Copy files from calling repo to action


I want to create a github docker container action that uses files from the repository using the action.

Do I need to check the repository out by myself or can I specify a point where the files are copied if it was checked out before?


Solution

  • Github actions do not have a concept of repository or branch. Each workflow is run in a container and only has that container to interact with.

    Actions can have inputs. You can create an input that should point to the location of the user's repository.

    In your action.yml:

    inputs:
      repo_path:
        description: 'The path to the repository in the current environment'
        required: true
    

    In your code, you can check for the repo_path input to get the path to the repository on the file system.

    You can also check if the GITHUB_WORKSPACE points to a git repository which means that the user had used the actions/checkout action in a prior step.