|
1 | 1 | name: Update golangci-lint version
|
2 | 2 |
|
3 | 3 | on:
|
| 4 | + pull_request: |
| 5 | + paths: |
| 6 | + - '.github/workflows/update-golangci-lint.yaml' |
4 | 7 | schedule:
|
5 | 8 | - cron: '0 0 * * 1' # Runs every Monday at midnight UTC
|
6 | 9 | workflow_dispatch: # Allows manual triggering
|
7 | 10 |
|
8 | 11 | jobs:
|
9 | 12 | update-golangci-lint:
|
10 | 13 | runs-on: ubuntu-latest
|
| 14 | + outputs: |
| 15 | + latest_version: ${{ steps.get_version.outputs.latest_version }} |
| 16 | + current_version: ${{ steps.check_version.outputs.current_version }} |
11 | 17 | steps:
|
12 | 18 | - name: Checkout repository
|
13 | 19 | uses: actions/checkout@v4
|
14 | 20 | with:
|
15 | 21 | fetch-depth: 0
|
16 |
| - |
17 | 22 | - name: Get latest golangci-lint version
|
18 | 23 | id: get_version
|
19 | 24 | run: |
|
20 |
| - LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name | sed 's/v//') |
21 |
| - echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV |
22 |
| - echo "Latest version: $LATEST_VERSION" |
23 |
| -
|
| 25 | + export LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name) |
| 26 | + echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV |
| 27 | + echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_OUTPUT |
24 | 28 | - name: Check current version in Makefile
|
25 | 29 | id: check_version
|
26 | 30 | run: |
|
27 |
| - CURRENT_VERSION=$(grep 'GOLANGCI_LINT_VERSION' hack/tools/Makefile | cut -d '=' -f2 | tr -d ' ') |
28 |
| - echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV |
29 |
| - echo "Current version: $CURRENT_VERSION" |
30 |
| -
|
| 31 | + export CURRENT_VERSION=$(grep 'GOLANGCI_LINT_VERSION ?=' hack/tools/Makefile | cut -d '=' -f2 | tr -d ' ') |
| 32 | + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV |
| 33 | + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT |
31 | 34 | - name: Update Makefile if needed
|
32 |
| - if: env.CURRENT_VERSION != env.LATEST_VERSION |
| 35 | + if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }} |
33 | 36 | run: |
|
34 |
| - sed -i "s/GOLANGCI_LINT_VERSION=.*/GOLANGCI_LINT_VERSION=${LATEST_VERSION}/" hack/tools/Makefile |
35 |
| -
|
36 |
| - - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # tag=v9.1.4 |
37 |
| - name: Commit changes |
| 37 | + sed -i "s/GOLANGCI_LINT_VERSION=.*/GOLANGCI_LINT_VERSION=${{ steps.get_version.outputs.latest_version }}/" hack/tools/Makefile |
| 38 | + - name: Commit changes |
| 39 | + if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }} |
| 40 | + run: | |
| 41 | + git config --global user.name "github-actions[bot]" |
| 42 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 43 | + git checkout -b update-golangci-lint-${{ steps.get_version.outputs.latest_version }} |
| 44 | + git add hack/tools/Makefile |
| 45 | + git commit -m "chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}" |
| 46 | + git push origin update-golangci-lint-${{ steps.get_version.outputs.latest_version }} |
| 47 | + - name: Create Pull Request |
| 48 | + if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }} |
| 49 | + uses: peter-evans/create-pull-request@v6 |
38 | 50 | with:
|
39 |
| - author_name: github-actions[bot] |
40 |
| - author_email: github-actions[bot]@users.noreply.github.com |
41 |
| - default_author: github_actor |
42 |
| - message: "chore: bump golangci-lint to v${LATEST_VERSION}" |
| 51 | + title: "🌱 chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}" |
| 52 | + body: "This PR updates golangci-lint to version v${{ steps.get_version.outputs.latest_version }}." |
| 53 | + branch: update-golangci-lint-${{ steps.get_version.outputs.latest_version }} |
| 54 | + labels: "area/dependency" |
0 commit comments