Action showing permission denied

I had many environmental variables so I used to gpg to encrypt those variables in a file.

I then made a script to decrypt that file and to store it the backend folder of my project during the run of the action

All this are to happen in the github action (see below the yml file)

That script of mine looks something like this:

#!/bin/sh

gpg --quiet --batch --yes --decrypt --passphrase="$DECRYPTER_PASSPHRASE" \
--output ./backend/.env ./.github/secrets/backend.env.gpg

My script is running well when I am executing this command in the project root

./.github/scripts/backend_decrypt.sh

But it fails during the github action

My backend-deploy.yml file is like this:


name: Backend Deploy

on:
  push:
    branches:
      - master
    paths:
      - 'backend/**'

jobs:
  backendDeploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - shell: bash
        env:
          DECRYPTER_PASSPHRASE: ${{secrets.DECRYPTER_PASSPHRASE}}
        run: >
          ./.github/scripts/backend_decrypt.sh
# fails at this point
      - run: |
          cat backend/.env
          pwd
          ls -a
          ls backend/
      - run: >
          ls -a
          ls -a backend/
          echo "Deployed to code-rush-backend.herokuapp.com"

It is giving me this error:

How can I fix this ? Please help

That most likely means that your ./.github/scripts/backend_decrypt.sh script doesn’t have the “execute” filesystem permission set. I assume you’re developing on Windows locally, which doesn’t have that kind of permission system.

You can tell git to add the permission anyway with this command:

git update-index --chmod=+x ./.github/scripts/backend_decrypt.sh

update-index is similar to add in that it adds the change to the index, so you’ll have to commit and push as usual.

1 Like

Thanks a lot @airtower-luna
This solved it

1 Like