From 917b4170ee0b2489f40c7653117ca267a2bf937b Mon Sep 17 00:00:00 2001 From: Chl Date: Sat, 31 Aug 2024 01:47:16 +0200 Subject: [PATCH] Finalization tryout... --- .../workflows/generate-release-zipfile.yml | 19 ++++++++++++------- action.yml | 11 +++++++---- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/.github/workflows/generate-release-zipfile.yml b/.github/workflows/generate-release-zipfile.yml index 8e5ed87..698a6c2 100644 --- a/.github/workflows/generate-release-zipfile.yml +++ b/.github/workflows/generate-release-zipfile.yml @@ -4,8 +4,8 @@ on: jobs: GenerateReleaseZipfile: runs-on: ubuntu-latest - # To allow access to the artifact with the GITHUB_TOKEN at the last step - permissions: read-all + # Trying to help access to the artifact with the GITHUB_TOKEN at the last step but didn't help. + #permissions: read-all steps: - name: Generate some content run: | @@ -18,6 +18,7 @@ jobs: echo tutu >> tutu.txt echo tutuuuuu >> tutu2.txt echo tutuuuuu >> "tutu tutu.txt" + # Github doesn't like special characters. #echo ratata >> 'tutu tutu*.txt' ls -R @@ -36,6 +37,7 @@ jobs: - name: Testing the artifact uploading id: "uploading" uses: ./myaction + # For comparison #uses: actions/upload-artifact@v4 with: path: | @@ -45,7 +47,7 @@ jobs: - name: "Cleanup Github" run: rm -rvf myaction - - name: Is there any output for the previous step ? + - name: Is there any output for the uploading step ? run: | set -x printf "steps.uploading.outputs.artifact-id: %s\n" "${{ steps.uploading.outputs.artifact-id }}" @@ -79,10 +81,13 @@ jobs: # - ...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: 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 )" - ) + 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>&1 )" \ + || wget -O "$DOWNLOAD_FILE" \ + "$( echo "$WGET_OUTPUT" | sed -n 's/^Location: \(.*\) \[following\]/\1/p' | tail -n 1 )" + + # unzip and check unzip "$DOWNLOAD_FILE" sha256sum -c "$SHASUM_FILE" diff --git a/action.yml b/action.yml index 68a3394..8b815d1 100644 --- a/action.yml +++ b/action.yml @@ -36,13 +36,15 @@ runs: steps: # ACTIONS_RUNTIME_TOKEN is not yet available (2024-08) for composite actions on Github : # https://github.com/actions/runner/issues/3046 - - name: Expose GitHub Runtime - if: env.ACTIONS_RUNTIME_TOKEN == '' - uses: "https://github.com/crazy-max/ghaction-github-runtime@v3" + # Forgejo tries to download this remote action even if it's not needed : + # uncomment if you want to run this action in Github. + #- name: Expose GitHub Runtime + # if: env.ACTIONS_RUNTIME_TOKEN == '' + # uses: "https://github.com/crazy-max/ghaction-github-runtime@v3" - name: Upload artifact (using v4) shell: sh - # id required for the outputs extraction + # id for reference in the outputs extraction id: uploading run: | # Some optional help for debugging. @@ -117,6 +119,7 @@ runs: ARTIFACT_ID="$( echo "$RESPONSE" | sed -n 's/.*"artifact_\?Id" *: *"\([^"]\+\)".*/\1/ip' )" echo artifact-id="$ARTIFACT_ID" >> $GITHUB_OUTPUT if [ "$GITHUB_SERVER_URL" = "https://github.com" ]; then + # note: as an alternative, there is https://api.github.com/repos/OWNER/REPO/actions/artifacts/ARTIFACT_ID echo artifact-url="$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_ID"/artifacts/"$ARTIFACT_ID" >> $GITHUB_OUTPUT else # Gitea & Forgejo : github.run_number instead of github.run_id and name of the artifact instead of artifact_id