Q:

Why when I use github actions CI for a gradle project I face "./gradlew: Permission denied" error?

I have a very simple gradle project and when I setup GitHub Actions CI I face this error:
Run ./gradlew clean dependencies
  ./gradlew clean dependencies
  shell: /bin/bash -e {0}
  env:
    JAVA_HOME: /opt/hostedtoolcache/Java/8.0.222/x64
    JAVA_HOME_8.0.222_x64: /opt/hostedtoolcache/Java/8.0.222/x64
/home/runner/work/_temp/8f29e484-fbb4-4e29-a02a-679519aec24c.sh: line 1: ./gradlew: Permission denied
##[error]Process completed with exit code 126.

A:

I found the answer!
I just had to change the gradlew file permission on the git repository to make it executable using this command:
git update-index --chmod=+x gradlew
git commit -m "Make gradlew executable"

it was simple but killed my time!

A:

To solve this issue, you might need to add chmod action before gradle one. Like this one:
- name: Change wrapper permissions
  run: chmod +x ./gradlew

So overall workflow file may look like this:
name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v1
    - name: Set up JDK 1.8
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Change wrapper permissions
      run: chmod +x ./gradlew
    - name: Build with Gradle
      run: ./gradlew build

