Skip to content

Commit

Permalink
Fix: GITHUB_TOKEN の権限周りを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
tsukumijima committed Nov 8, 2024
1 parent 238ea34 commit 6f74521
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions .github/actions/download-engine/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ inputs:
description: "ダウンロードする対象。"
required: false
default: ""
token:
description: "GitHub API トークン。"
required: false
default: ${{ github.token }}

outputs:
run_path:
Expand All @@ -42,7 +46,7 @@ runs:
shell: bash
run: |
curl -s https://api.github.com/repos/${{ inputs.repo }}/releases \
-H 'authorization: Bearer ${{ github.token }}' \
-H 'authorization: Bearer ${{ inputs.token }}' \
-H 'content-type: application/json' > $TEMPDIR/releases.json
cat $TEMPDIR/releases.json
Expand All @@ -67,15 +71,15 @@ runs:
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 ${{ github.token }}" > $TEMPDIR/download_name.txt
echo $LIST_URL | xargs curl -sSL -H "Authorization: Bearer ${{ inputs.token }}" > $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 ${{ github.token }}" $URL -o $TEMPDIR/$i &
curl -sSL -H "Authorization: Bearer ${{ inputs.token }}" $URL -o $TEMPDIR/$i &
done
for job in `jobs -p`; do
wait $job
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
cache-version: v2
# GNUコマンド
sed: ${{ startsWith(matrix.os, 'macos-') && 'gsed' || 'sed' }}
# github.token の権限を拡張
# secrets.GITHUB_TOKEN の権限を拡張
permissions:
contents: read
packages: read
Expand Down Expand Up @@ -221,6 +221,7 @@ jobs:
version: ${{ env.AIVISSPEECH_ENGINE_VERSION }}
dest: ${{ github.workspace }}/AivisSpeech-Engine
target: ${{ matrix.aivisspeech_engine_asset_name }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Merge AivisSpeech Engine into prepackage/
if: startsWith(matrix.artifact_name, 'windows-') || startsWith(matrix.artifact_name, 'linux-')
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
e2e-test:
runs-on: ${{ matrix.os }}
needs: [config]
# github.token の権限を拡張
# secrets.GITHUB_TOKEN の権限を拡張
permissions:
contents: read
packages: read
Expand Down Expand Up @@ -129,6 +129,7 @@ jobs:
version: ${{ env.AIVISSPEECH_ENGINE_VERSION }}
dest: ${{ github.workspace }}/AivisSpeech-Engine
target: ${{ matrix.aivisspeech_engine_asset_name }}
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup
run: |
Expand Down

0 comments on commit 6f74521

Please sign in to comment.