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 betteralign to gh actions #239

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 31 additions & 1 deletion .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
lint:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: read # for golangci/golangci-lint-action to fetch pull requests
pull-requests: write # for betteralign to comment on PR
checks: write # for golangci/golangci-lint-action to annotate Pull Requests
name: Lint Go code
runs-on: ubuntu-latest
Expand All @@ -29,6 +29,36 @@ jobs:
version: v1.54
args: --timeout 10m --exclude SA5011 --verbose --issues-exit-code=0
only-new-issues: true
- name: Run betteralign
id: betteralign
run: |
go install github.com/dkorunic/betteralign/cmd/betteralign@latest
{
echo 'BETTERALIGN_OUTPUT<<EOF'
betteralign ./... 2>&1 || true
echo "EOF"
} >> "$GITHUB_ENV"
- uses: actions/github-script@v7
env:
BETTERALIGN_OUTPUT: '${{env.BETTERALIGN_OUTPUT}}'
with:
script: |
const {BETTERALIGN_OUTPUT} = process.env
const output = `#### Betteralign 🤖

\`\`\`bash
$ betteralign ./...
${BETTERALIGN_OUTPUT}
\n\`\`\`

*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: output
})

govulncheck:
runs-on: ubuntu-latest
Expand Down