Adding scripts to your workflow
You can use GitHub Actions workflows to run scripts.
You 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 therun keyword to execute the commandnpm install -g bats on the runner.
jobs:example-job:runs-on:ubuntu-lateststeps:-run:npminstall-gbatsTo 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 therun 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, seeSetting a default shell and working directory.
jobs:example-job:runs-on:ubuntu-latestdefaults:run:working-directory:./scriptssteps:-name:Checkouttherepositorytotherunneruses:actions/checkout@v5-name:Runascriptrun:./my-script.sh-name:Runanotherscriptrun:./my-other-script.shAny 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 commandgit 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:
jobs:example-job:runs-on:ubuntu-latestdefaults:run:working-directory:./scriptssteps:-name:Checkouttherepositorytotherunneruses:actions/checkout@v5-name:Makethescriptfilesexecutablerun:chmod+xmy-script.shmy-other-script.sh-name:Runthescriptsrun:| ./my-script.sh ./my-other-script.shFor more information about therun keyword, seeWorkflow syntax for GitHub Actions.