diff --git a/.github/actions/spotless-apply/action.yml b/.github/actions/spotless-apply/action.yml new file mode 100644 index 000000000..571ee6e8f --- /dev/null +++ b/.github/actions/spotless-apply/action.yml @@ -0,0 +1,39 @@ +name: 'spotless-apply' +description: 'Run spotlessApply and create PR' +author: 'yuhuyoyo' + +inputs: + token: + description: 'broadbot token for creating PR' + required: true +outputs: + spotlesscheck: + description: 'success if the code base is spotless and no further action needed' + value: ${{ steps.spotless-check.outcome }} +runs: + using: "composite" + steps: + - name: spotless check + id: spotless-check + run: ./gradlew spotlessCheck + shell: bash + - name: spotless apply + id: spotless-apply + if: failure() && steps.spotless-check.outcome == 'failure' + run: ./gradlew spotlessApply + shell: bash + - name: create PR + id: create-pr + uses: peter-evans/create-pull-request@v4 + if: failure() && steps.spotless-apply.outcome == 'success' + with: + token: ${{ inputs.token }} + commit-message: "Terra CLI spotless apply" + committer: terracli-bot + author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> + title: "Terra CLI spotless apply" + branch: "actions/spotlessApply" + delete-branch: true + body: | + Run spotlessApply. + *Note: This PR was opened by the [nightly-test GitHub Actions workflow](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).* diff --git a/.github/workflows/tests-nightly.yml b/.github/workflows/tests-nightly.yml index ca8d87a77..40c2c0a12 100644 --- a/.github/workflows/tests-nightly.yml +++ b/.github/workflows/tests-nightly.yml @@ -23,6 +23,12 @@ jobs: with: java-version: 11 distribution: 'temurin' + - name: Run spotlessApply + id: spotless-apply + if: always() + uses: ./.github/actions/spotless-apply + with: + token: ${{ secrets.BROADBOT_GITHUB_TOKEN }} - name: Cache Gradle packages id: cache_gradle uses: actions/cache@v2 @@ -118,7 +124,8 @@ jobs: L2="Unit: ${{ steps.run_unit_tests.outcome }} " L3="Integ (Source): ${{ steps.run_integration_tests_against_source_code.outcome }} " L4="Integ (Release): ${{ steps.run_integration_tests_against_release.outcome }}" - bold="$L2 | $L3 | $L4" + L5="Lint: ${{ steps.spotless-apply.outputs.spotlesscheck }}" + bold="$L2 | $L3 | $L4 | $L5" text="Link to " if [ "${{ job.status }}" == "success" ]; then text=":white_check_mark: $text"