diff --git a/.github/actions/gh-api-update-status/action.yml b/.github/actions/gh-api-update-check/action.yml similarity index 54% rename from .github/actions/gh-api-update-status/action.yml rename to .github/actions/gh-api-update-check/action.yml index c52f1fddf629c..6cccf41c95f1c 100644 --- a/.github/actions/gh-api-update-status/action.yml +++ b/.github/actions/gh-api-update-check/action.yml @@ -16,8 +16,8 @@ # under the License. # --- -name: "Update Commit Status Check" -description: "Update the status of a commit check using the GH CLI" +name: "Update Check Run" +description: "Update the status of a commit check using the GH CLI. See https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#create-a-check-run" inputs: # Composite actions do not support typed parameters. Everything is treated as a string # See: https://github.com/actions/runner/issues/2238 @@ -39,23 +39,43 @@ inputs: description: "The text to display next to the check" default: "" required: false - context: - description: "The name of the status check" + title: + description: "The title of the status check" required: true - state: - description: "The state of the check. Can be one of: error, failure, pending, success" + status: + description: "The status of the check. Can be one of: queued, in_progress, completed, waiting, requested, pending" required: true + conclusion: + description: "Required if status is 'completed'. Can be one of: action_required, cancelled, failure, neutral, success, skipped, stale, timed_out" + required: false runs: using: "composite" steps: - - name: Update Check + - if: inputs.conclusion == '' + shell: bash + env: + GH_TOKEN: ${{ inputs.gh-token }} + run: | + gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${{ inputs.repository }}/check-runs \ + -f "head_sha=${{ inputs.commit_sha }}" \ + -f "status=${{ inputs.status }}" \ + -f "details_url=${{ inputs.url }}" \ + -f "output[title]=${{ inputs.title }}" \ + -f "output[summary]=${{ inputs.description }}" \ + -f "name=${{ inputs.title }}" + - if: inputs.conclusion != '' shell: bash env: GH_TOKEN: ${{ inputs.gh-token }} run: | gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${{ inputs.repository }}/statuses/${{ inputs.commit_sha }} \ - -f "state=${{ inputs.state }}" -f "target_url=${{ inputs.url }}" \ - -f "description=${{ inputs.description }}" \ - -f "context=${{ inputs.context }}" + /repos/${{ inputs.repository }}/check-runs \ + -f "head_sha=${{ inputs.commit_sha }}" \ + -f "status=${{ inputs.status }}" \ + -f "conclusion=${{ inputs.conclusion }}" \ + -f "details_url=${{ inputs.url }}" \ + -f "output[title]=${{ inputs.title }}" \ + -f "output[summary]=${{ inputs.description }}" \ + -f "name=${{ inputs.title }}" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 21297e1f1d2ff..cbb64b63a1cfc 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,11 +39,19 @@ jobs: matrix: java: [ 21, 17, 11, 8 ] name: Compile and Check Java ${{ matrix.java }} + outputs: + is-draft: ${{ steps.check-draft-pr.outputs.is-draft }} steps: - name: Env run: printenv env: GITHUB_CONTEXT: ${{ toJson(github) }} + - name: Check for Draft PR + id: check-draft-pr + if: | + github.event_name == 'pull_request' && + github.event.pull_request.draft + run: echo "is-draft=true" >> "$GITHUB_OUTPUT" - name: Checkout code uses: actions/checkout@v4 with: @@ -86,6 +94,7 @@ jobs: test: needs: validate + if: ${{ ! needs.validate.outputs.is-draft }} runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/ci-complete.yml b/.github/workflows/ci-complete.yml index 611a6578b6796..2d5401404920a 100644 --- a/.github/workflows/ci-complete.yml +++ b/.github/workflows/ci-complete.yml @@ -70,15 +70,16 @@ jobs: path: ~/.gradle/build-scan-data # This is where Gradle buffers unpublished build scan data when --no-scan is given - name: Handle missing scan if: ${{ steps.download-build-scan.outcome == 'failure' }} - uses: ./.github/actions/gh-api-update-status + uses: ./.github/actions/gh-api-update-check with: gh-token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} commit_sha: ${{ github.event.workflow_run.head_sha }} url: '${{ github.event.workflow_run.html_url }}' description: 'Could not find build scan' - context: 'Gradle Build Scan / Java ${{ matrix.java }}' - state: 'error' + title: 'Gradle Build Scan / Java ${{ matrix.java }}' + status: 'completed' + conclusion: 'skipped' - name: Publish Scan id: publish-build-scan if: ${{ steps.download-build-scan.outcome == 'success' }} @@ -98,23 +99,25 @@ jobs: fi - name: Handle failed publish if: ${{ failure() && steps.publish-build-scan.outcome == 'failure' }} - uses: ./.github/actions/gh-api-update-status + uses: ./.github/actions/gh-api-update-check with: gh-token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} commit_sha: ${{ github.event.workflow_run.head_sha }} url: '${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}' description: 'The build scan failed to be published' - context: 'Gradle Build Scan / Java ${{ matrix.java }}' - state: 'error' + title: 'Gradle Build Scan / Java ${{ matrix.java }}' + status: 'completed' + conclusion: 'failure' - name: Update Status Check if: ${{ steps.publish-build-scan.outcome == 'success' }} - uses: ./.github/actions/gh-api-update-status + uses: ./.github/actions/gh-api-update-check with: gh-token: ${{ secrets.GITHUB_TOKEN }} repository: ${{ github.repository }} commit_sha: ${{ github.event.workflow_run.head_sha }} url: ${{ steps.publish-build-scan.outputs.build-scan-url }} description: 'The build scan was successfully published' - context: 'Gradle Build Scan / Java ${{ matrix.java }}' - state: 'success' + title: 'Gradle Build Scan / Java ${{ matrix.java }}' + status: 'completed' + conclusion: 'success' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280483fc3b528..f8d27b3372186 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,7 +21,7 @@ on: - 'trunk' pull_request: - types: [ opened, synchronize, reopened ] + types: [ opened, synchronize, ready_for_review, reopened ] branches: - 'trunk'