Why am I getting a GitHub action "permission denied" error when deploying to PythonAnywhere despite adding execution permissions

78 views Asked by At

I'm having an issue with GitHub actions permission denied error when trying to deploy to PythonAnywhere.

GitHub Actions Deploy to PythonAnywhere Error Message:

Run git update-index --chmod=+x deploy.sh; ./deploy.sh
  git update-index --chmod=+x deploy.sh; ./deploy.sh
  shell: /usr/bin/bash -e {0}
  env:
    PYTHONPATH: /home/runner/work/cosmic_cruiser/cosmic_cruiser/
    pythonLocation: /opt/hostedtoolcache/Python/3.9.18/x64
    PKG_CONFIG_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib/pkgconfig
    Python_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
    Python2_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
    Python3_ROOT_DIR: /opt/hostedtoolcache/Python/3.9.18/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.18/x64/lib
    DEMO_PA_PWD: ***
/home/runner/work/_temp/d8dbb980-ed66-4e73-bbae-b48afa95da3a.sh: line 1: ./deploy.sh: Permission denied
Error: Process completed with exit code 126.

main.yml:

# This is a workflow to test and deploy our demo app.

name: Demo CI/CD

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]
  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

env:
  PYTHONPATH: /home/runner/work/cosmic_cruiser/cosmic_cruiser/

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    environment: pa_deploy

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: Set up Python 3.9
        uses: actions/setup-python@v4
        with:
          # Semantic version range syntax or exact version of a Python version
          python-version: '3.9'
          # Optional - x64 or x86 architecture, defaults to x64
          architecture: 'x64'
      # You can test your matrix by printing the current Python version
      - name: Display Python version
        run: python -c "import sys; print(sys.version)"

      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      - name: Install MongoDB
        uses: supercharge/[email protected]

      - name: Install Python packages.
        run: make dev_env

      - name: Run Python tests.
        run: make all_tests
        
      - name: Deploy to PythonAnywhere
        run: git update-index --chmod=+x deploy.sh; ./deploy.sh
        env:
          DEMO_PA_PWD: ${{secrets.DEMO_PA_PWD}}

Note: All the files in the repository (such as the README) has all their execute bits set (not sure why). In addition, when I tried to turn it off for deploy.sh I was unable to.

I've tried the following:

  1. Check if the execute bit is on for deploy.sh (it was): 0 -rwxrwxrwx 1 user user 757 Feb 1 17:29 deploy.sh
  2. Set the permission via the command line and pushed the changes: git update-index --chmod=+x deploy.sh
  3. Explicitly set the permission in main.yml in the deploy step:
      - name: Deploy to PythonAnywhere
        run: git update-index --chmod=+x deploy.sh; ./deploy.sh
        env:
          DEMO_PA_PWD: ${{secrets.DEMO_PA_PWD}}
  1. Reclone the repository
0

There are 0 answers