Lint workflow creates issue on bad action #4
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: Lint | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v2 | |
with: | |
go-version: 1.22.3 | |
- name: Install golangci-lint | |
run: | | |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.51.2 | |
- name: Run golangci-lint | |
id: lint | |
run: | | |
golangci-lint run --out-format json > golangci-lint-report.json | |
if [ -s golangci-lint-report.json ]; then | |
echo "Lint issues found" | |
echo "::set-output name=lint_failed::true" | |
else | |
echo "No lint issues found" | |
echo "::set-output name=lint_failed::false" | |
fi | |
- name: Create GitHub Issue if Lint Issues Found | |
if: steps.lint.outputs.lint_failed == 'true' | |
uses: peter-evans/create-issue-from-file@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: Linting Issue Found | |
content-filepath: golangci-lint-report.json | |
labels: lint |