🌱 Fix workflows/update-golangci-lint #11
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
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 | |
workflow_dispatch: # Allows manual triggering | |
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: | | |
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: | | |
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 | |
run: | | |
sed -i "s/GOLANGCI_LINT_VERSION=.*/GOLANGCI_LINT_VERSION=${{ steps.get_version.outputs.latest_version }}/" hack/tools/Makefile | |
sed -i "s/GOLANGCI_LINT_VERSION=.*/GOLANGCI_LINT_VERSION=foo/" hack/tools/Makefile | |
- name: Commit changes | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
git checkout -b update-golangci-lint-${{ steps.get_version.outputs.latest_version }} | |
git add hack/tools/Makefile | |
git commit -m "chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}" | |
git push origin update-golangci-lint-${{ steps.get_version.outputs.latest_version }} | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
title: "🌱 chore: bump golangci-lint to v${{ steps.get_version.outputs.latest_version }}" | |
body: "This PR 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" |