Self CI/CD with download of the artifact
All checks were successful
/ GenerateReleaseZipfile (push) Successful in 1m10s
All checks were successful
/ GenerateReleaseZipfile (push) Successful in 1m10s
This commit is contained in:
parent
c2d7e3d9bc
commit
705e2d717c
3 changed files with 41 additions and 5 deletions
|
@ -23,7 +23,7 @@ jobs:
|
|||
|
||||
- name: Testing the artifact uploading
|
||||
id: "uploading"
|
||||
uses: "https://entrepot.xlii.si/actions/upload-artifact-with-wget@v4"
|
||||
uses: "${{ github.server_url }}/${{ github.repository }}@${{ github.sha }}"
|
||||
with:
|
||||
path: |
|
||||
toto
|
||||
|
@ -33,3 +33,32 @@ jobs:
|
|||
run: |
|
||||
set -x
|
||||
printf "steps.uploading.outputs.artifact-id: %s\n" "${{ steps.uploading.outputs.artifact-id }}"
|
||||
printf "steps.uploading.outputs.artifact-url: %s\n" "${{ steps.uploading.outputs.artifact-url }}"
|
||||
|
||||
- name: Check the content of the uploaded artifact
|
||||
run: |
|
||||
# Stop at first error and be verbose
|
||||
set -ex
|
||||
|
||||
# Create some temporary files/directory
|
||||
DOWNLOAD_FILE="$( mktemp )"
|
||||
SHASUM_FILE="$( mktemp )"
|
||||
TEST_ARTIFACT_DIR="$( mktemp -d )"
|
||||
|
||||
# Get the fingerprint of our test
|
||||
find . -type f -exec sha256sum \{\} \; > "$SHASUM_FILE"
|
||||
# Little optional checkup
|
||||
cat "$SHASUM_FILE"
|
||||
|
||||
cd "$TEST_ARTIFACT_DIR"
|
||||
# In case the repository becomes private, we add our GITHUB_TOKEN to the artifact-url.
|
||||
MY_AUTHENTICATED_URL="$( echo "${{ steps.uploading.outputs.artifact-url }}" | sed "s#^\(https\?://\)#\1$GITHUB_TOKEN\@#" )"
|
||||
wget -O "$DOWNLOAD_FILE" "$MY_AUTHENTICATED_URL"
|
||||
unzip "$DOWNLOAD_FILE"
|
||||
sha256sum -c "$SHASUM_FILE"
|
||||
|
||||
# Cleanup
|
||||
cd -
|
||||
rm -f "$DOWNLOAD_FILE"
|
||||
rm -f "$SHASUM_FILE"
|
||||
rm -rf "$TEST_ARTIFACT_DIR"
|
||||
|
|
|
@ -62,8 +62,8 @@ steps:
|
|||
- name: Simple checkout
|
||||
run: |
|
||||
git init
|
||||
GITHUB_AUTHENTICATED_URL="$( echo "$GITHUB_SERVER_URL" | sed "s#^\(https\?://\)#\1$GITHUB_TOKEN\@#" )"
|
||||
git remote add origin "$GITHUB_AUTHENTICATED_URL"/"$GITHUB_REPOSITORY"
|
||||
MY_AUTHENTICATED_URL="$( echo "$GITHUB_SERVER_URL" | sed "s#^\(https\?://\)#\1$GITHUB_TOKEN\@#" )"
|
||||
git remote add origin "$MY_AUTHENTICATED_URL"/"$GITHUB_REPOSITORY"
|
||||
# Little and optional speed optimization
|
||||
git config --local gc.auto 0
|
||||
git fetch --no-tags --prune --no-recurse-submodules --depth=1 origin "$GITHUB_SHA"
|
||||
|
|
11
action.yml
11
action.yml
|
@ -80,7 +80,7 @@ runs:
|
|||
# (note 2: if it fails here, it probably means you are using the busybox
|
||||
# variant of wget which can't (as of 2024-08-26) use the PUT method.
|
||||
# Install the full one beforehand : apt install wget / pkg add wget / ...)
|
||||
wget --method PUT --body-file "$MYUPLOAD" "$SIGNED_UPLOAD_URL&comp=block"
|
||||
wget -O /dev/null --method PUT --body-file "$MYUPLOAD" "$SIGNED_UPLOAD_URL&comp=block"
|
||||
|
||||
# Finalize the artifact
|
||||
RESPONSE="$( wget -O - \
|
||||
|
@ -91,7 +91,14 @@ runs:
|
|||
)"
|
||||
|
||||
# Store the outputs
|
||||
echo artifact-id="$( echo "$RESPONSE" | sed -n 's/.*"artifactId" *: *"\([^"]\+\)".*/\1/p' )" >> $GITHUB_OUTPUT
|
||||
ARTIFACT_ID="$( echo "$RESPONSE" | sed -n 's/.*"artifactId" *: *"\([^"]\+\)".*/\1/p' )"
|
||||
echo artifact-id="$ARTIFACT_ID" >> $GITHUB_OUTPUT
|
||||
if [ "$GITHUB_SERVER_URL" = "https://github.com" ]; then
|
||||
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
|
||||
echo artifact-url="$GITHUB_SERVER_URL"/"$GITHUB_REPOSITORY"/actions/runs/"$GITHUB_RUN_NUMBER"/artifacts/"$INPUT_NAME" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# Cleanup
|
||||
if [ "${{ inputs.compression }}" == "true" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue