gradle / gradle-build-action

Execute your Gradle build and trigger dependency submission
https://github.com/marketplace/actions/gradle-build-action
MIT License
671 stars 97 forks source link

Add support to output command output to GITHUB_STEP_SUMMARY #833

Closed peterdietz closed 1 year ago

peterdietz commented 1 year ago

Other build pipelines allow me to output the text output of a command to the GitHub Step Summary, such that the build will display some additional information. And not just hidden inside of the logs of a step.

Would you consider adding a feature for this? Maybe add a parameter write-to-step-summary: true?

In bash, I'll do something like:

      - name: Report Something
        run: cat output.md >> $GITHUB_STEP_SUMMARY
        shell: bash

But in gradle-build-action, I would like something like this:

      - name: Print Application Build Version
        uses: gradle/gradle-build-action@v2
        with:
          arguments: printVersion
          cache-read-only: false
          gradle-version: ${{ env.GRADLE_VERSION }}
          write-to-step-summary: true

As I integrate more of my jobs with Build/Publishing artifacts, its very helpful to sanity check which version of the app wrote an artifact. Thank you!

bigdaz commented 1 year ago

In order to achieve this, you can separate the gradle-build-action step from the actual Gradle execution, like so:

      - name: Setup Gradle
        uses: gradle/gradle-build-action@v2
        with:
          cache-read-only: false
          gradle-version: ${{ env.GRADLE_VERSION }}
      - name: Print Application Build Version
        run: gradle printVersion >> $GITHUB_STEP_SUMMARY

In fact, I would recommend that you always use gradle-build-action as a "Setup Gradle" step. This will likely become a more formal recommendation in the future.

Because of this simple workaround, I'm reluctant to add a new feature for this purpose.

peterdietz commented 1 year ago

That recommended use of gradle-build-action as a "setup step" makes so much more sense. I didn't think I actually had access to "real" gradle command, but thought I instead had to pipe everything thru arguments to interact. Yes, now that I can just run a command, there is no need for a one-off custom printing parameter. (Because then the next thing I'll ask for a custom one-off write to file parameter). And this setup-step and run is universal. Thank you!