Search code examples
githubgithub-actionsgithub-flavored-markdown

How to create a folder in github actions?


I am new to github actions and need some help.

I have a readme.md file for a collection of scripts that is 100s of lines long. I want to translate it into different languages using this github action (https://github.com/dephraiim/translate-readme)

But instead of putting all the files it creates into the main directory. I want to create a folder inside my directory and put all these created files in there.

So in the main directory I have all the scripts I've written and one readme.md file. What I want is something like this.

Maindirectory/newreadmefolder/(all the new language readme.md files)


Solution

  • A directory can be created this way.:

          - name: Create dir
            run: |
              mkdir mydirname
    

    This has to be added in steps part like in this full action file:

    name: mkdir example
    
    on:
      push:
        branches: [ '**' ]
      
      workflow_dispatch:
    
    
    jobs:
      build:
        runs-on: ubuntu-latest
    
        steps:
          - name: Create dir
            run: |
              mkdir mydirname
    

    If you also want to move some file, you can add something like mv readme-*.md mydirname at the end, e.g.:

          - name: Create dir
            run: |
              mkdir mydirname
              mv readme-*.md mydirname