Review comments #209
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Review comments" | |
on: | |
workflow_run: | |
workflows: [GTN Tutorial Linting] | |
types: [completed] | |
jobs: | |
comment: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
persist-credentials: false | |
- uses: reviewdog/action-setup@v1 | |
with: | |
reviewdog_version: latest | |
- name: 'Download artifact' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "reviewdog" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
const fs = require('fs'); | |
const path = require('path'); | |
const temp = '${{ runner.temp }}/artifacts'; | |
if (!fs.existsSync(temp)){ | |
fs.mkdirSync(temp); | |
} | |
fs.writeFileSync(path.join(temp, 'reviewdog.zip'), Buffer.from(download.data)); | |
- name: 'Unzip artifact' | |
run: unzip "${{ runner.temp }}/artifacts/reviewdog.zip" | |
- name: Add review comments | |
run: | | |
. env.sh | |
env | grep CI_ | sort | |
# We are overriding the logic within reviewdog, to trick it into thinking it's running outside | |
# https://github.com/reviewdog/reviewdog/issues/706 | |
unset GITHUB_EVENT_PATH | |
unset GITHUB_ACTIONS | |
env | grep GITHUB_ | grep -v TOKEN | sort | |
cat reviewdog.txt | reviewdog -efm="%f:%l: %m" -reporter=github-pr-review -log-level debug -tee -filter-mode nofilter -name 'GTN Lint' | |
cat reviewdog.json | reviewdog -reporter=github-pr-review -f=rdjsonl -log-level debug -tee -filter-mode nofilter -name 'GTN Lint' | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |