-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
284 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
name: Verification of Preserving Artifact Upload | ||
|
||
on: | ||
push: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Build: | ||
name: Upload artifact | ||
runs-on: ubuntu-24.04 | ||
|
||
steps: | ||
- name: 🖉 Build 1 | ||
run: | | ||
echo "Document 1 $(date --utc '+%d.%m.%Y - %H:%M:%S')" > document1.txt | ||
echo "Analysis log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > analysis.log | ||
echo "Build log $(date --utc '+%d.%m.%Y - %H:%M:%S')" > build.log | ||
mkdir -p bin | ||
echo "Program $(date --utc '+%d.%m.%Y - %H:%M:%S')" > bin/program.py | ||
chmod u+x bin/program.py | ||
mkdir -p lib | ||
echo "Library $(date --utc '+%d.%m.%Y - %H:%M:%S')" > lib/common.py | ||
chmod +x lib/common.py | ||
- name: 🔎 Inspect directory structure | ||
run: | | ||
tree . | ||
- name: 📤 Upload artifact | ||
uses: pyTooling/upload-artifact@main | ||
with: | ||
name: release | ||
path: | | ||
document1.txt | ||
*.log | ||
bin/ | ||
lib/*.py | ||
# if-no-files-found: error | ||
# retention-days: 1 | ||
|
||
Verify: | ||
name: Verify artifact content | ||
runs-on: ubuntu-24.04 | ||
needs: | ||
- Build | ||
|
||
steps: | ||
- name: 📥 Download artifact | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: release | ||
|
||
- name: 🔎 Inspect downloaded artifact content | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
echo "List directory content" | ||
ls -lAh . | ||
echo "----------------------------------------" | ||
echo -n "Does tarball exist ... " | ||
if [[ ! -f __upload_artifact__.tar ]]; then | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
echo -e "${ANSI_LIGHT_RED}Artifact doesn't contain a tar file named '__upload_artifact__.tar'.${ANSI_NOCOLOR}" | ||
exit 1 | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" | ||
fi | ||
- name: 📦 Extract tarball | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
echo -n "Extracting tarball ... " | ||
tar -xf __upload_artifact__.tar | ||
if [[ $? -ne 0 ]]; then | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" | ||
fi | ||
- name: 🔎 Inspect extracted tarball | ||
run: | | ||
tree . | ||
- name: 📋 Verify extracted tarball content | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
expected=( | ||
"document1.txt" | ||
"analysis.log" | ||
"build.log" | ||
"bin/program.py" | ||
"lib/common.py" | ||
) | ||
errors=0 | ||
for file in "${expected[@]}"; do | ||
echo -n "Checking '${file}' ... " | ||
if [[ -f "$file" ]]; then | ||
echo -e "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
echo -e "${ANSI_LIGHT_RED}Extracted artifact doesn't contain file '${file}'.${ANSI_NOCOLOR}" | ||
errors=$((errors + 1)) | ||
fi | ||
done | ||
echo "" | ||
if [[ $errors -ne 0 ]]; then | ||
echo -e "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}" | ||
fi | ||
- name: 📋 Verify file permissions | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
expected=( | ||
"bin/program.py" | ||
"lib/common.py" | ||
) | ||
errors=0 | ||
for file in "${expected[@]}"; do | ||
echo -n "Checking '${file}' ... " | ||
if [[ -x "$file" ]]; then | ||
echo -e "${ANSI_LIGHT_GREEN}[PASSED]${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
echo -e "${ANSI_LIGHT_RED}File '${file}' isn't executable.${ANSI_NOCOLOR}" | ||
errors=$((errors + 1)) | ||
fi | ||
done | ||
echo "" | ||
if [[ $errors -ne 0 ]]; then | ||
echo -e "${ANSI_LIGHT_RED}Counted ${errors} errors.${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}No errors found.${ANSI_NOCOLOR}" | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,6 @@ | ||
# Preserving Artifact Upload Action | ||
|
||
**Based on:** | ||
* [actions/upload-artifact#38 - upload-artifact does not retain artifact permissions (08. Sep. 2024)](https://github.com/actions/upload-artifact/issues/38#issuecomment-2336484584) | ||
* [Gist: | ||
rcdailey/download-tar-action.yml](https://gist.github.com/rcdailey/cd3437bb2c63647126aa5740824b2a4f) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Upload (preserving) Artifact | ||
description: Tarball files before uploading the artifact to preserve file privileges. | ||
author: Patrick Lehmann (@Paebbels) | ||
|
||
inputs: | ||
name: | ||
description: "Name of the artifact." | ||
type: string | ||
path: | ||
description: A list of file/directory pattern to be tarballed and uploaded as an artifact. | ||
required: true | ||
type: string | ||
# if-no-files-found: | ||
# retention-days: | ||
# compression-level: | ||
overwrite: | ||
required: false | ||
default: false | ||
type: boolean | ||
# include-hidden-files: | ||
temp_tarball: | ||
type: string | ||
required: false | ||
default: '__upload_artifact__.tar' | ||
|
||
outputs: | ||
artifact-id: | ||
# description: "Random number" | ||
value: ${{ steps.upload.outputs.artifact-id }} | ||
artifact-url: | ||
value: ${{ steps.upload.outputs.artifact-url }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Create tarball from given file patterns | ||
id: prepare | ||
shell: bash | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
PATTERNS=() | ||
while IFS=$'\r\n' read -r pattern; do | ||
# skip empty or comment lines | ||
[[ "${pattern}" == "" || "${pattern:0:1}" == "#" ]] && continue | ||
PATTERNS+=($pattern) | ||
done <<<'${{ inputs.path }}' | ||
# echo "PATTERNS: ${PATTERNS[@]}" | ||
echo -n "Creating temporary tarball ... " | ||
tar -cf "${{ inputs.temp_tarball }}" "${PATTERNS[@]}" | ||
if [[ $? -ne 0 ]]; then | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" | ||
fi | ||
# https://github.com/actions/upload-artifact | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
id: upload | ||
with: | ||
name: ${{ inputs.name }} | ||
path: ${{ inputs.temp_tarball }} | ||
overwrite: ${{ inputs.overwrite }} | ||
|
||
- name: Remove temporary tarball | ||
id: cleanup | ||
shell: bash | ||
run: | | ||
set +e | ||
ANSI_LIGHT_RED="\e[91m" | ||
ANSI_LIGHT_GREEN="\e[92m" | ||
ANSI_NOCOLOR="\e[0m" | ||
echo -n "Removing temporary tarball ... " | ||
rm -f "${{ inputs.temp_tarball }}" | ||
if [[ $? -ne 0 ]]; then | ||
echo -e "${ANSI_LIGHT_RED}[FAILED]${ANSI_NOCOLOR}" | ||
else | ||
echo -e "${ANSI_LIGHT_GREEN}[OK]${ANSI_NOCOLOR}" | ||
fi |