Running a bash script #26403
-
Hi there, However, now I need to run a custom script in a single repo and, I feel a separate action is too much. I’d like to be able to do run a bash script saved at ROOT/.github/script.sh but I can’t figure out how to specify the path in the run step of the workflow below.
Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 8 replies
-
With that setup the path to the script is relative to the root of your repository, so if your script is |
Beta Was this translation helpful? Give feedback.
-
To be more explicit, you can write If you want to know the full path where the working copy resides in the runner, then you can do The absolute path should be
|
Beta Was this translation helpful? Give feedback.
-
airtower-luna:
Thanks for the reply. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your help. |
Beta Was this translation helpful? Give feedback.
-
what say i want to pass in a value (say from a gh secret) to the shell_script how would I do that? |
Beta Was this translation helpful? Give feedback.
-
I use like this: - name: Build and Deploy Script
working-directory: ${{ github.workspace }}/PROJECT_FOLDER
run: bash ./publish-script.sh |
Beta Was this translation helpful? Give feedback.
-
worked for me after i added the action jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Run bash script
run: bash file.sh
|
Beta Was this translation helpful? Give feedback.
With that setup the path to the script is relative to the root of your repository, so if your script is
.github/script.sh
that’s all that’s needed in the run step. Remember that the file must be marked as executable, or you need to explicitly call bash with the script as parameter.