Search code examples
androidgithub-actions

'set-env' error when trying to build Android app using GitHub Actions - don't understand how to use Environment Files in this circumstance


I am new to GitHub Actions and want to build and deploy my Android app to "internal testing" at the Google Play store. I have seen some good articles on it, but have been running into the 'set-env' error. I have followed the link but still do not understand how to apply it to my specific use case.

The set-env command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the ACTIONS_ALLOW_UNSECURE_COMMANDS environment variable to true. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/

Here is the error: enter image description here

There seems to be some good examples without the environment files, which seems like the right way to go. I am following this, this, and this. All have some simple steps, but this is where I am having the problem:

- name: set up JDK 1.8
  uses: actions/[email protected]
  with:
    java-version: 1.8

My yaml file looks like this:

name: Build

on:
  push:
    branches: 
      - '*'

jobs:
  build:
    name: Build
    runs-on: ubuntu-latest

    steps:
    - name: checkout
      uses: actions/[email protected]
    - name: set up JDK 1.8
      uses: actions/[email protected]
      with:
        java-version: 1.8
        
    - name: Grant execute permission for gradlew
      run: chmod +x gradlew
      
    - name: Build with Gradle
      run: ./gradlew build

I need to get through this before I can tackle the signing, etc.


Solution

  • use an updated version of the actions/setup-java step, like:

        steps:
        - name: checkout
          uses: actions/[email protected]
        - name: set up JDK 1.8
          uses: actions/setup-java@
          with:
            distribution: 'zulu' # See 'Supported distributions' for available options
            java-version: '8'