master保持和gf的master一致 #17
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
# Copyright GoFrame Author(https://goframe.org). All Rights Reserved. | |
# | |
# This Source Code Form is subject to the terms of the MIT License. | |
# If a copy of the MIT was not distributed with this file, | |
# You can obtain one at https://github.com/gogf/gf. | |
name: GolangCI-Lint | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
- personal/** | |
- feature/** | |
- enhance/** | |
- fix/** | |
- feat/** | |
pull_request: | |
branches: | |
- master | |
- develop | |
- personal/** | |
- feature/** | |
- enhance/** | |
- fix/** | |
- feat/** | |
jobs: | |
golangci: | |
strategy: | |
matrix: | |
go-version: [ 'stable' ] | |
name: golangci-lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Golang ${{ matrix.go-version }} | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
# Required: specify the golangci-lint version without the patch version to always use the latest patch. | |
version: v1.62.2 | |
only-new-issues: true | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
args: --timeout 3m0s | |
- name: Install gci | |
run: go install github.com/daixiang0/gci@latest | |
- name: Run gci | |
run: | | |
gci write --custom-order \ | |
--skip-generated \ | |
--skip-vendor \ | |
-s standard \ | |
-s blank \ | |
-s default \ | |
-s dot \ | |
-s "prefix(github.com/gogf/gf/v2)" \ | |
-s "prefix(github.com/gogf/gf/cmd)" \ | |
-s "prefix(github.com/gogf/gf/contrib)" \ | |
-s "prefix(github.com/gogf/gf/example)" \ | |
./ | |
- name: Check for changes | |
# Check if the event is a push or a pull request from a forked repository | |
if: github.event_name == 'push'|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) | |
run: | | |
if [[ -n "$(git status --porcelain)" ]]; then | |
echo "HAS_CHANGES=true" >> $GITHUB_ENV | |
else | |
echo "HAS_CHANGES=false" >> $GITHUB_ENV | |
fi | |
- name: Commit and push changes | |
if: env.HAS_CHANGES == 'true' | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git add . | |
git commit -m "Apply gci import order changes" | |
git push origin HEAD:$(git rev-parse --abbrev-ref HEAD) |