Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add: [annotation-check] action to check if any previous job in a workflow has any annotation #28

Merged
merged 1 commit into from May 20, 2021

Conversation

TrueBrain
Copy link
Member

This replaces the long blob:

    steps:
    - name: Get check suite ID
      id: check_suite_id
      uses: octokit/request-action@v2.x
      with:
        route: GET /repos/{repository}/actions/runs/{run_id}
        repository: ${{ github.repository }}
        run_id: ${{ github.run_id }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Get check runs
      id: check_runs
      uses: octokit/request-action@v2.x
      with:
        route: GET /repos/{repository}/check-suites/{check_suite_id}/check-runs
        repository: ${{ github.repository }}
        check_suite_id: ${{ fromJson(steps.check_suite_id.outputs.data).check_suite_id }}
      env:
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    - name: Check annotations
      shell: bash
      run: |
        echo '[
        ${{ toJson(fromJson(steps.check_runs.outputs.data).check_runs.*.output.title) }}, ${{ toJson(fromJson(steps.check_runs.outputs.data).check_runs.*.output.summary) }}
        ]' | jq '.[0] as $t | .[1] as $s | reduce range(.[0] | length) as $i ([]; . + [if $t[$i] then $t[$i] + ": " + $s[$i] else empty end]) | .[]'

        exit $(echo '${{ toJson(fromJson(steps.check_runs.outputs.data).check_runs.*.output.annotations_count) }}' | jq 'add')

with the much easier to read:

    steps:
    - name: Check annotations
      uses: OpenTTD/actions/annotation-check@v2

Result can be seen here:
https://github.com/TrueBrain/OpenTTD-actions/runs/2630416316?check_suite_focus=true

@TrueBrain TrueBrain merged commit fdb6336 into OpenTTD:master May 20, 2021
@TrueBrain TrueBrain deleted the annotation branch May 20, 2021 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants