Allow downloading releases from private repos (#15)

Closes #14

Reviewed-on: https://code.forgejo.org/actions/forgejo-release/pulls/15
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: benniekiss <benniekiss@noreply.code.forgejo.org>
Co-committed-by: benniekiss <benniekiss@noreply.code.forgejo.org>
This commit is contained in:
benniekiss 2024-07-06 20:04:23 +00:00 committed by earl-warren
parent eb0fcc44a1
commit de47e391d3
2 changed files with 8 additions and 2 deletions

View file

@ -21,6 +21,12 @@ jobs:
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" 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 }}" 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 - name: testdata/nested-upload-download
run: | run: |
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}" export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"

View file

@ -107,7 +107,7 @@ upload() {
setup_api() { setup_api() {
if ! which jq curl ; then if ! which jq curl ; then
apt-get -qq update apt-get -qq update
apt-get install -y -qq jq curl wget apt-get install -y -qq jq curl
fi fi
} }
@ -149,7 +149,7 @@ download() {
cd $RELEASE_DIR cd $RELEASE_DIR
api GET repos/$REPO/releases/tags/$TAG > $TMP_DIR/assets.json 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 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 done
) )
} }