{"meta":{"title":"Adding scripts to your workflow","intro":"You can use GitHub Actions workflows to run scripts.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/enterprise-cloud@latest/actions","title":"GitHub Actions"},{"href":"/en/enterprise-cloud@latest/actions/how-tos","title":"How-tos"},{"href":"/en/enterprise-cloud@latest/actions/how-tos/write-workflows","title":"Write workflows"},{"href":"/en/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-what-workflows-do","title":"Choose what workflows do"},{"href":"/en/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-what-workflows-do/add-scripts","title":"Add scripts"}],"documentType":"article"},"body":"# Adding scripts to your workflow\n\nYou can use GitHub Actions workflows to run scripts.\n\nYou can use a GitHub Actions workflow to run scripts and shell commands, which are then executed on the assigned runner. This example demonstrates how to use the `run` keyword to execute the command `npm install -g bats` on the runner.\n\n```yaml\njobs:\n  example-job:\n    runs-on: ubuntu-latest\n    steps:\n      - run: npm install -g bats\n```\n\nTo use a workflow to run a script stored in your repository you must first check out the repository to the runner. Having done this, you can use the `run` keyword to run the script on the runner. The following example runs two scripts, each in a separate job step. The location of the scripts on the runner is specified by setting a default working directory for run commands. For more information, see [Setting a default shell and working directory](/en/enterprise-cloud@latest/actions/how-tos/write-workflows/choose-what-workflows-do/set-default-values-for-jobs).\n\n```yaml\njobs:\n  example-job:\n    runs-on: ubuntu-latest\n    defaults:\n      run:\n        working-directory: ./scripts\n    steps:\n      - name: Check out the repository to the runner\n        uses: actions/checkout@v6\n      - name: Run a script\n        run: ./my-script.sh\n      - name: Run another script\n        run: ./my-other-script.sh\n```\n\nAny scripts that you want a workflow job to run must be executable. You can do this either within the workflow by passing the script as an argument to the interpreter that will run the script - for example, `run: bash script.sh` - or by making the file itself executable. You can give the file the execute permission by using the command `git update-index --chmod=+x PATH/TO/YOUR/script.sh` locally, then committing and pushing the file to the repository. Alternatively, for workflows that are run on Linux and Mac runners, you can add a command to give the file the execute permission in the workflow job, prior to running the script:\n\n```yaml\njobs:\n  example-job:\n    runs-on: ubuntu-latest\n    defaults:\n      run:\n        working-directory: ./scripts\n    steps:\n      - name: Check out the repository to the runner\n        uses: actions/checkout@v6\n      - name: Make the script files executable\n        run: chmod +x my-script.sh my-other-script.sh\n      - name: Run the scripts\n        run: |\n          ./my-script.sh\n          ./my-other-script.sh\n```\n\nFor more information about the `run` keyword, see [Workflow syntax for GitHub Actions](/en/enterprise-cloud@latest/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idstepsrun)."}