Skip to content

Commit

Permalink
made job runs conditional for lint
Browse files Browse the repository at this point in the history
  • Loading branch information
h4ck3rk3y committed Feb 19, 2024
1 parent fae997d commit 1152987
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/gofmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,25 @@ on:
merge_group:

jobs:
check-if-code-change:
runs-on: ubuntu-latest
outputs:
change: ${{ steps.check.change }}
steps:
- uses: actions/checkout@v4
with:
go-version: '1.20'
fetch-depth: 0
- run: |
if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then
echo "::set-output name=change::false"
else
echo "::set-output name=change::true"
fi
id: check
gofmt:
needs: check-if-code-change
if: ${{ needs.check-if-code-change.outputs.change == true }}
name: gofmt
runs-on: ubuntu-latest
steps:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,25 @@ env:
GOLINT_VERSION: v1.53.3

jobs:
check-if-code-change:
runs-on: ubuntu-latest
outputs:
change: ${{ steps.check.change }}
steps:
- uses: actions/checkout@v4
with:
go-version: '1.20'
fetch-depth: 0
- run: |
if git --no-pager diff --exit-code origin/main...HEAD -- . ':!docs' ':!*.md'; then
echo "::set-output name=change::false"
else
echo "::set-output name=change::true"
fi
id: check
golangci:
needs: check-if-code-change
if: ${{ needs.check-if-code-change.outputs.change == true }}
name: golang-lint
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 1152987

Please sign in to comment.