diff --git a/.github/workflows/update-golangci-lint.yaml b/.github/workflows/update-golangci-lint.yaml index aa15a2dee9..fc5b37e49f 100644 --- a/.github/workflows/update-golangci-lint.yaml +++ b/.github/workflows/update-golangci-lint.yaml @@ -1,42 +1,53 @@ name: Update golangci-lint version on: + pull_request: + paths: + - '.github/workflows/update-golangci-lint.yaml' schedule: - - cron: '0 0 * * 1' # Runs every Monday at midnight UTC + - cron: '0 0 * * *' # Runs every day at midnight UTC workflow_dispatch: # Allows manual triggering +permissions: + pull-requests: write + jobs: update-golangci-lint: runs-on: ubuntu-latest + outputs: + latest_version: ${{ steps.get_version.outputs.latest_version }} + current_version: ${{ steps.check_version.outputs.current_version }} steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Get latest golangci-lint version id: get_version run: | - LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name | sed 's/v//') - echo "LATEST_VERSION=$LATEST_VERSION" >> $GITHUB_ENV - echo "Latest version: $LATEST_VERSION" - + export LATEST_VERSION=$(curl -s https://api.github.com/repos/golangci/golangci-lint/releases/latest | jq -r .tag_name) + echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_ENV + echo "LATEST_VERSION=${LATEST_VERSION}" >> $GITHUB_OUTPUT - name: Check current version in Makefile id: check_version run: | - CURRENT_VERSION=$(grep 'GOLANGCI_LINT_VERSION' hack/tools/Makefile | cut -d '=' -f2 | tr -d ' ') - echo "CURRENT_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV - echo "Current version: $CURRENT_VERSION" - + export CURRENT_VERSION=$(grep 'GOLANGCI_LINT_VERSION ?=' hack/tools/Makefile | cut -d '=' -f2 | tr -d ' ') + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_ENV + echo "CURRENT_VERSION=${CURRENT_VERSION}" >> $GITHUB_OUTPUT - name: Update Makefile if needed - if: env.CURRENT_VERSION != env.LATEST_VERSION + if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }} run: | - sed -i "s/GOLANGCI_LINT_VERSION=.*/GOLANGCI_LINT_VERSION=${LATEST_VERSION}/" hack/tools/Makefile - - - uses: EndBug/add-and-commit@a94899bca583c204427a224a7af87c02f9b325d5 # tag=v9.1.4 - name: Commit changes + sed -i "s/GOLANGCI_LINT_VERSION ?= .*/GOLANGCI_LINT_VERSION ?= ${{ steps.get_version.outputs.latest_version }}/" hack/tools/Makefile + - name: Create Pull Request + if: ${{ steps.check_version.outputs.current_version != steps.get_version.outputs.latest_version }} + uses: peter-evans/create-pull-request@dd2324fc52d5d43c699a5636bcf19fceaa70c284 # tag=v7.0.7 with: - author_name: github-actions[bot] - author_email: github-actions[bot]@users.noreply.github.com - default_author: github_actor - message: "chore: bump golangci-lint to v${LATEST_VERSION}" + commit-message: "This commit updates golangci-lint to version v${{ steps.get_version.outputs.latest_version }}." + title: ":seedling: chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}" + body: | + This PR was generated by GH workflow `update-golangci-lint` and + updates golangci-lint to version v${{ steps.get_version.outputs.latest_version }}. + branch: update-golangci-lint-${{ steps.get_version.outputs.latest_version }} + labels: "area/dependency" + add-paths: | + - hack/tools/Makefile