An Interest In:
Web News this Week
- April 27, 2024
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
GitHub Actions: Fixing the 'Permission Denied' error for shell scripts
Ever encountered this frustratingly vague "Permission denied" error when trying to run a bash script in an GitHub action workflow?
"Permission denied" means that your script file does not have the "execute" permission set. On Mac and Linux you can use the chmod
command to make script files executable, but Windows does not support this.
How to fix it
Luckily, Git offers a command that works with Windows. Run:
git update-index --chmod=+x your_script.sh
locally to make the bash script executable. Once you commit and push the change to your GitHub repository the script will be allowed to run in your GitHub action.
NB: you will need to run this command then commit and push the change to GitHub for any bash script you create or rename on a Windows machine in order for it to run in a GitHub action.
How to run a bash script in a GitHub action
That's great Aileen, but how do I even add a script to a GitHub action?
Here is an example action which runs a your_script.sh
script on commit to the main
branch of your repository.
# https://gist.github.com/aileen-r/f74e680fb47ebc8b29a9f1cc452a5da9# This is a basic workflow to help you get started with Actionsname: Run a shell script# Controls when the workflow will runon: # Triggers the workflow on push but only for the main branch push: branches: [ main ]# A workflow run is made up of one or more jobs that can run sequentially or in paralleljobs: # This workflow contains a single job called "build" build: # The type of runner that the job will run on runs-on: ubuntu-latest # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 # Runs a single command using the runners shell - name: Run shell script run: ./your_script.sh
If you're new to GitHub actions, GitHub has an excellent quickstart guide.
Original Link: https://dev.to/aileenr/github-actions-fixing-the-permission-denied-error-for-shell-scripts-4gbl
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To