refactor: add more linters #5
Workflow file for this run
This file contains 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: dstlled-diff | |
on: | |
pull_request: | |
permissions: | |
contents: read | |
pull-requests: write | |
jobs: | |
dstlled-diff: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- id: get-dstlled-diff | |
uses: dhth/dstll-action-test@v0.1.14 | |
with: | |
directory: '.' | |
pattern: '**.go' | |
starting-commit: ${{ github.event.pull_request.base.sha }} | |
ending-commit: ${{ github.event.pull_request.head.sha }} | |
- run: echo "$DIFF" | |
env: | |
DIFF: ${{ steps.get-dstlled-diff.outputs.diff }} | |
- uses: actions/github-script@v7 | |
with: | |
github-token: ${{ github.token }} | |
script: | | |
// 1. Retrieve existing bot comments for the PR | |
const { data: comments } = await github.rest.issues.listComments({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
}) | |
const botComment = comments.find(comment => { | |
return comment.user.type === 'Bot' && comment.body.includes('dstlled-diff') | |
}) | |
// 2. Prepare format of the comment | |
const output = `### dstlled-diff | |
> ${{ github.event.pull_request.base.ref }}..${{ github.event.pull_request.head.ref }} -- '**.go' | |
<details><summary> expand </summary> | |
\`\`\`diff\n | |
${{ steps.get-dstlled-diff.outputs.diff }} | |
\`\`\` | |
</details>`; | |
// 3. If we have a comment, update it, otherwise create a new one | |
if (botComment) { | |
github.rest.issues.updateComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: botComment.id, | |
body: output | |
}) | |
} else { | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}) | |
} |