From de47e391d31cd6dc81998dfbe4a96c0c9b3d18ac Mon Sep 17 00:00:00 2001 From: benniekiss Date: Sat, 6 Jul 2024 20:04:23 +0000 Subject: [PATCH] Allow downloading releases from private repos (#15) Closes #14 Reviewed-on: https://code.forgejo.org/actions/forgejo-release/pulls/15 Reviewed-by: earl-warren Co-authored-by: benniekiss Co-committed-by: benniekiss --- .forgejo/workflows/integration.yml | 6 ++++++ forgejo-release.sh | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/integration.yml b/.forgejo/workflows/integration.yml index 711e207..d257bc6 100644 --- a/.forgejo/workflows/integration.yml +++ b/.forgejo/workflows/integration.yml @@ -21,6 +21,12 @@ jobs: export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" forgejo-test-helper.sh run_workflow testdata/upload-download http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} testuser upload-download forgejo-release "${{ steps.forgejo.outputs.token }}" + - name: testdata/upload-download-private + run: | + export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" + curl -X 'POST' 'http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }}/api/v1/user/repos' -H 'accept: application/json' -H 'Content-Type: application/json' -d '{"name": "upload-download-private","private": true}' + forgejo-test-helper.sh run_workflow testdata/upload-download http://testuser:admin1234@${{ steps.forgejo.outputs.host-port }} testuser upload-download-private forgejo-release "${{ steps.forgejo.outputs.token }}" + - name: testdata/nested-upload-download run: | export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" diff --git a/forgejo-release.sh b/forgejo-release.sh index b9aaf03..e113b4c 100755 --- a/forgejo-release.sh +++ b/forgejo-release.sh @@ -107,7 +107,7 @@ upload() { setup_api() { if ! which jq curl ; then apt-get -qq update - apt-get install -y -qq jq curl wget + apt-get install -y -qq jq curl fi } @@ -149,7 +149,7 @@ download() { cd $RELEASE_DIR api GET repos/$REPO/releases/tags/$TAG > $TMP_DIR/assets.json jq --raw-output '.assets[] | "\(.name) \(.browser_download_url)"' < $TMP_DIR/assets.json | while read name url ; do - wget --quiet -O $name $url + curl --fail -H "Authorization: token $TOKEN" -o $name -L $url done ) }