Files
carbon-lang/.github/workflows/pre_commit_suggestions.yaml
T
Jon Ross-Perkins 0405fff68c Update to checkout v4 (#3759)
Noticed due to
https://github.com/carbon-language/carbon-lang/actions/runs/8207272518

```
Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/checkout@v3. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
```

I'm expecting we can just update the version number on these.
2024-03-08 20:25:04 +00:00

56 lines
1.9 KiB
YAML

# Part of the Carbon Language project, under the Apache License v2.0 with LLVM
# Exceptions. See /LICENSE for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# Create PR suggestions based on problems found by pre-commit action.
name: pre-commit-suggestions
# This action is run whenever the `pre-commit` action finishes. Because the
# `pre-commit` action is an unprivileged action running on (for example) the
# `pull_request` event, it's run without write permissions to the repository, so
# we use a separate privileged `workflow_run` action here to pick up its results
# and convert them into suggestion comments.
#
# This action is only run from the workflow file on the trunk branch. Changes to
# this file will not take effect until they are merged to trunk.
on:
workflow_run:
workflows: [pre-commit]
types:
- completed
permissions:
pull-requests: write
jobs:
pull-request-suggestions:
# Only generate suggestions if pre-commit for a PR failed.
if: |
github.event.workflow_run.conclusion == 'failure' &&
github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: reviewdog/action-setup@v1
with:
reviewdog_version: latest
- uses: actions/checkout@v4
- name: Download pre-commit output
uses: actions/download-artifact@v4
with:
name: pre-commit output
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
# Use https://github.com/reviewdog/reviewdog to create PR suggestions
# matching the diff that pre-commit created.
- name: Create suggestions
env:
REVIEWDOG_GITHUB_API_TOKEN:
${{ secrets.CARBON_INFRA_BOT_FOR_REVIEWDOG }}
run: |
cat ./diff | \
GITHUB_EVENT_PATH=./event \
reviewdog -f=diff -f.diff.strip=1 -reporter=github-pr-review