From 599c6372d84c6c8e5e7074d4c0346f998671ac6d Mon Sep 17 00:00:00 2001 From: LamGC Date: Tue, 14 Jan 2025 09:31:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=20jq=20=E4=BB=A5?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E5=8F=AF=E4=BB=A5=E8=8E=B7=E5=8F=96=E7=A1=AE?= =?UTF-8?q?=E5=88=87=E7=9A=84=20tag=5Fname.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/check-updates.yml | 2 ++ update-version.sh | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-updates.yml b/.github/workflows/check-updates.yml index c23c37e..544ddf9 100644 --- a/.github/workflows/check-updates.yml +++ b/.github/workflows/check-updates.yml @@ -19,6 +19,8 @@ jobs: uses: actions/checkout@v3 with: token: ${{ secrets.CHECK_UPDATES_TOKEN }} + - name: Install dependencies + run: sudo apt-get install -y jq - name: Check updates run: chmod +x ./update-version.sh && ./update-version.sh - name: Get latest version diff --git a/update-version.sh b/update-version.sh index 4984325..5e0f7e6 100644 --- a/update-version.sh +++ b/update-version.sh @@ -1,4 +1,12 @@ -LATEST_VERSION=$(curl -s https://api.github.com/repos/jenkinsci/docker-agent/releases/latest | grep tag_name | cut -d '"' -f 4) +#!/bin/bash + +LATEST_VERSION=$(curl -s https://api.github.com/repos/jenkinsci/docker-agent/releases/latest | jq -r '.tag_name') +CURL_EXIT_CODE=$? +if [ $CURL_EXIT_CODE -ne 0 ] || [ -z "$LATEST_VERSION" ]; then + echo "Failed to retrieve the latest version" + exit 1 +fi + if [ "$LATEST_VERSION" != "$(cat LATEST_VERSION)" ]; then echo "$LATEST_VERSION" > LATEST_VERSION -fi +fi \ No newline at end of file