From afa43d3e2111ec22998b90d444f0d7e75c7aceb7 Mon Sep 17 00:00:00 2001
From: tsukumi <tsukumijima@users.noreply.github.com>
Date: Sat, 9 Nov 2024 03:04:34 +0900
Subject: [PATCH] =?UTF-8?q?Fix:=20=E3=83=97=E3=83=A9=E3=82=A4=E3=83=99?=
 =?UTF-8?q?=E3=83=BC=E3=83=88=E3=83=AA=E3=83=9D=E3=82=B8=E3=83=88=E3=83=AA?=
 =?UTF-8?q?=E3=81=8B=E3=82=89=E3=82=A8=E3=83=B3=E3=82=B8=E3=83=B3=E3=82=92?=
 =?UTF-8?q?=E3=83=80=E3=82=A6=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=81=A7?=
 =?UTF-8?q?=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .github/actions/download-engine/action.yml | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/.github/actions/download-engine/action.yml b/.github/actions/download-engine/action.yml
index fe39b1e9..ea1620ea 100644
--- a/.github/actions/download-engine/action.yml
+++ b/.github/actions/download-engine/action.yml
@@ -69,18 +69,25 @@ runs:
 
         # リリース情報からファイル一覧の txt を取得
         cat $TEMPDIR/target.json | jq -er '[.assets[] | select(.name | contains("'$TARGET'") and endswith(".7z.txt"))][0]' > $TEMPDIR/assets_txt.json
-        LIST_URL=$(cat $TEMPDIR/assets_txt.json | jq -er '.browser_download_url')
-        echo "7z.txt url: $LIST_URL"
-        echo $LIST_URL | xargs curl -sSL -H "Authorization: Bearer ${{ inputs.token }}" > $TEMPDIR/download_name.txt
+
+        # アセットIDを取得してダウンロード
+        ASSET_ID=$(cat $TEMPDIR/assets_txt.json | jq -er '.id')
+        curl -sL -H 'Accept: application/octet-stream' \
+          "https://${{ inputs.token }}@api.github.com/repos/${{ inputs.repo }}/releases/assets/$ASSET_ID" \
+          > $TEMPDIR/download_name.txt
+
         echo "Files to download:"
         cat $TEMPDIR/download_name.txt | sed -e 's|^|- |'
 
         # ファイル一覧の txt にあるファイルをダウンロード
         for i in $(cat $TEMPDIR/download_name.txt); do
-          URL=$(cat $TEMPDIR/target.json | jq -er "[.assets[] | select(.name == \"$i\")][0].browser_download_url")
-          echo "Download url: $URL, dest: $TEMPDIR/$i"
-          curl -sSL -H "Authorization: Bearer ${{ inputs.token }}" $URL -o $TEMPDIR/$i &
+          ASSET_ID=$(cat $TEMPDIR/target.json | jq -er "[.assets[] | select(.name == \"$i\")][0].id")
+          echo "Download asset id: $ASSET_ID, name: $i"
+          curl -sL -H 'Accept: application/octet-stream' \
+            "https://${{ inputs.token }}@api.github.com/repos/${{ inputs.repo }}/releases/assets/$ASSET_ID" \
+            -o "$TEMPDIR/$i" &
         done
+
         for job in `jobs -p`; do
           wait $job
         done