How to create new directory in repository via Bash in starter workflow?

Hello! Could somebody help me to create new directory in repository via Bash?

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the $default-branch branch
    branches: [ $default-branch ]
    branches: [ $default-branch ]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
  # This workflow contains a single job called "build"
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: # What to write here? Simple "mkdir <name>" doesn't work.


You just need to use the mkdir command to create the new directory via Bash shell.
Basic syntax:

mkdir [options] <name_of_directory>
  1. The <name_of_directory> can be a relative path to the current working directory.

    • Create a single level sub-directory in current working directory:

      mkdir subdir1
    • Create multiple levels sub-directory in current working directory, the ‘-p’ option is required:

      mkdir -p subdir1/subdir2
  2. The <name_of_directory> also can be an absolute path of the new directory, the ‘-p’ option also is required when creating multiple levels directory.

    mkdir -p /home/subdir1/subdir2
1 Like

What do you mean by “a simple mkdir doesn’t work”?
It should create the directory, but if you want to commit that to the repository, then you must place a file inside. Git doesn’t support tracking empty folders.

A common convention is to place a file called .gitkeep in such placeholder folders, either without content or with a brief description of what this file is for.

1 Like