To pass Gradle property as argument we have 2 choices:
- Use env syntax and Gradle convention for environment variables:
uses: eskatos/gradle-command-action@v1
with:
env:
ORG_GRADLE_PROJECT_someSecret: 1234
arguments: build
The issue of this approach is that it doesn't support properties with dots (very common practice, because of properties file)
- Pass property as command-line argument:
uses: eskatos/gradle-command-action@v1
with:
arguments: build -PsomeSecret=1234
Works fine until you have 1-2 property, but becomes issue if you have many of them, multiline support would help but it also have issues in YML, requires special syntax and not very convenient to use, it also easy to forgot slash in command
So I suggest adding support for gradle properties in yml syntax:
uses: eskatos/gradle-command-action@v1
with:
properties:
someSecret: 1234
arguments: build
Tho, there is an issue with it, because key with dot requires escaping in YML:
some.secret
should be escaped like:
"[some.secret]"
Still fine, but not perfect. There is another option. Support dot as yml separator:
properties:
some:
secret: 1234
For 1 simple property it may be overkill and escape will work just fine
But check this real-life example:
- name: Build
uses: eskatos/gradle-command-action@v1
with:
arguments: build --info -PsomeService.prod.apiKey=${{ secrets.SOME_SERVICE_API_KEY }} -PsomeService.prod.secret=${{ secrets.SOME_SERVICE_API_SECRET }} -PsomeService.prod.projectId=${{ secrets.SOME_SERVICE_PROJECT_ID }}
As you see, now it's not easy to follow what is going on. it will be better with nested properties syntax:
- name: Build
uses: eskatos/gradle-command-action@v1
with:
arguments: build
properties:
someService:
prod:
apiKey: ${{ secrets.SOME_SERVICE_API_KEY }}
secret: ${{ secrets.SOME_SERVICE_API_SECRET }}
projectId: ${{ secrets.SOME_SERVICE_PROJECT_ID }}
So much better even if debug and dev environments are configured
Maybe it should be considered to do the same for system properties, which are also very common
If you think it reasonable, I may try to implement it and contribute