Skip to content

Commit fc2c57a

Browse files
authored
Merge pull request #2453 from kubernetes-sigs/cilintfix
🌱 Fix workflows/update-golangci-lint
2 parents 7e9c7b0 + 0e00832 commit fc2c57a

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

Diff for: .github/workflows/update-golangci-lint.yaml

+30-19
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,53 @@
11
name: Update golangci-lint version
22

33
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/update-golangci-lint.yaml'
47
schedule:
5-
- cron: '0 0 * * 1' # Runs every Monday at midnight UTC
8+
- cron: '0 0 * * *' # Runs every day at midnight UTC
69
workflow_dispatch: # Allows manual triggering
710

11+
permissions:
12+
pull-requests: write
13+
814
jobs:
915
update-golangci-lint:
1016
runs-on: ubuntu-latest
17+
outputs:
18+
latest_version: ${{ steps.get_version.outputs.latest_version }}
19+
current_version: ${{ steps.check_version.outputs.current_version }}
1120
steps:
1221
- name: Checkout repository
1322
uses: actions/checkout@v4
1423
with:
1524
fetch-depth: 0
16-
1725
- name: Get latest golangci-lint version
1826
id: get_version
1927
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-
28+
export LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name)
29+
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV
30+
echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_OUTPUT
2431
- name: Check current version in Makefile
2532
id: check_version
2633
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-
34+
export CURRENT_VERSION=$(grep 'GOLANGCI_LINT_VERSION ?=' hack/tools/Makefile | cut -d '=' -f2 | tr -d ' ')
35+
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV
36+
echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT
3137
- name: Update Makefile if needed
32-
if: env.CURRENT_VERSION != env.LATEST_VERSION
38+
if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }}
3339
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
40+
sed -i "s/GOLANGCI_LINT_VERSION ?= .*/GOLANGCI_LINT_VERSION ?= ${{ steps.get_version.outputs.latest_version }}/" hack/tools/Makefile
41+
- name: Create Pull Request
42+
if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }}
43+
uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # tag=v7.0.7
3844
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}"
45+
commit-message: "This commit updates golangci-lint to version v${{ steps.get_version.outputs.latest_version }}."
46+
title: ":seedling: chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}"
47+
body: |
48+
This PR was generated by GH workflow `update-golangci-lint` and
49+
updates golangci-lint to version v${{ steps.get_version.outputs.latest_version }}.
50+
branch: update-golangci-lint-${{ steps.get_version.outputs.latest_version }}
51+
labels: "area/dependency"
52+
add-paths: |
53+
- hack/tools/Makefile

0 commit comments

Comments
 (0)