Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Github»Running Github Actions in a Sub Directory

    Running Github Actions in a Sub Directory

    RahulBy RahulMarch 11, 20221 Min ReadUpdated:March 15, 2022

    Github Actions provides us an easier way to setup CI/CD for the application. We can build any application on Github events and deploy to the servers.

    The default all commands are executed at root directory of the application. In some cases, you need to execute any command for the sub directories. It’s possible by setting the working-directory directive in the configuration file.

    Running Command in Subdirectory with Github Actions

    For example, your application have composer.json file under the “app” directory. In that case, use the following configuration to run composer install under app directory.

    YAML
    1
    2
    3
    4
        - name: Install composer dependencies
          run: |
            composer install --no-scripts
          working-directory: ./app

    In the above configuration the “composer install –no-scripts” command will be executed under “./app” directory. You can set any directory path by changing the value of working-directory.

    Below is a complete action configuration file used in our actual project.

    YAML
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    # This is an sample workflow for learning  working-directory option
     
    on:
      push:
        branches: [ main ]
      pull_request:
        branches: [ main ]
     
    name: CI
     
    jobs:
      phpunit:
        runs-on: ubuntu-latest
     
        steps:
        - uses: actions/[email protected]
          with:
            fetch-depth: 1
        - name: Install composer dependencies
          run: |
            composer install --no-scripts
          working-directory: ./app
        - name: Prepare Application
          run: |
            php artisan key:generate
          working-directory: ./app
        - name: Run Testsuite
          run: vendor/bin/phpunit tests/
          working-directory: ./app

    Conclusion

    In this tutorial, you have learned running commands in subdirectory with Github actions.

    actions github
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleHow to Change Windows Hostname (Computer Name)
    Next Article How to Start & Stop Windows Service via Command Line

    Related Posts

    Adding a New SSH Key in GitHub

    Updated:April 1, 20223 Mins Read

    Deploy Angular App to Firebase with Github Actions

    5 Mins Read

    How to Setup Your System with Multiple Git Accounts

    Updated:December 4, 20204 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.