Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Github»Running Github Actions in a Sub Directory

    Running Github Actions in a Sub Directory

    By RahulMarch 15, 20221 Min Read

    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.

    Advertisement

    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.

    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.

    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

    Related Posts

    Monitoring Github Public Repositories and Send Notification

    Shell Script to Check Github Public Repositories And Notify

    Adding a New SSH Key in GitHub

    Adding a New SSH Key to Your GitHub Account

    Deploy Angular App to Firebase with Github Actions

    Add A Comment

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • 20 Basic Linux Commands for the Beginners (Recommended)
    • tail Command in Linux with Examples
    • What is a Orphan Process in Unix/Linux
    • How To Display Warning Message to Unauthorized SSH Access
    • How to Set a Custom SSH Login Banner and MOTD
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

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