From e1c23abe1bd7a3aa916a73ebb29d68c1398361e7 Mon Sep 17 00:00:00 2001 From: Chl Date: Sat, 31 Aug 2024 01:02:14 +0200 Subject: [PATCH] Let's check if we broke something with Forgejo... --- .github/workflows/generate-release-zipfile.yml | 9 ++++++++- action.yml | 1 - 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-release-zipfile.yml b/.github/workflows/generate-release-zipfile.yml index c53d3c7..8e5ed87 100644 --- a/.github/workflows/generate-release-zipfile.yml +++ b/.github/workflows/generate-release-zipfile.yml @@ -72,8 +72,15 @@ jobs: # TODO : can't get it to work :-/ #wget --header "Authorization: Bearer $GITHUB_TOKEN" -O "$DOWNLOAD_FILE" "${{ steps.uploading.outputs.artifact-url }}" + # Oh boy... We're gone beyond salvation but let's try to explain: + # - the api.github.com accepts the GITHUB_TOKEN in the Authorization + # header (but not the ACTIONS_RUNTIME_TOKEN, nor the GITHUB_TOKEN as + # part of the URL like https://$GITHUB_TOKEN@api.github.com/...) + # - ...but we get redirect to Windows.net/Azure data warehouse which refuses GITHUB_TOKEN... + # -> so, if the api.github.com fails, we try to extract the redirect location and hit it without any header. + # ('beginning to wonder if Github's changing master to main was also a part of a plot to complexify our lives...) TMP_WGET_OUTPUT="$( mktemp )" - wget -O "$DOWNLOAD_FILE" --header "Authorization: token $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts/${{ steps.uploading.outputs.artifact-id }}/zip" 2>"$TMP_WGET_OUTPUT" || ( + wget -O "$DOWNLOAD_FILE" --header "Authorization: Bearer $GITHUB_TOKEN" "https://api.github.com/repos/$GITHUB_REPOSITORY/actions/artifacts/${{ steps.uploading.outputs.artifact-id }}/zip" 2>"$TMP_WGET_OUTPUT" || ( wget -O "$DOWNLOAD_FILE" "$( sed -n 's/^Location: \(.*\) \[following\]/\1/p' "$TMP_WGET_OUTPUT" | tail -n 1 )" ) unzip "$DOWNLOAD_FILE" diff --git a/action.yml b/action.yml index 78a6700..5c53fd6 100644 --- a/action.yml +++ b/action.yml @@ -89,7 +89,6 @@ runs: # We get a JSON with an signedUploadUrl similar to : # https://entrepot.xlii.si/twirp/github.actions.results.api.v1.ArtifactService/UploadArtifact?sig=yWWEI8tIIECp8D7E5TVh4_6G2pZxWaVdQcSYaCsx5s0=&expires=2024-08-26+07%3A20%3A49.886890537+%2B0200+CEST&artifactName=mymodule-1.2.3.zip&taskID=63 SIGNED_UPLOAD_URL="$( echo "$RESPONSE" | sed -n 's/.*"signed_\?[uU]pload_\?[uU]rl" *: *"\([^"]\+\)".*/\1/p' )" - printf "%s" "$SIGNED_UPLOAD_URL" | base64 # Upload our file # (note: adding '&comp=block' at the end of the URL)