mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
8c1972c335
* Fix parameter expansion when uploading multiple files * On download, ensure target directory exists * Rename encryption-secret -> encryptionSecret * Remove incorrect secret access from e2e test action * Add missing checkout action to workflows using our download action * Fix spacing * Fix upload action uploading whole directory structure instead of target files * Explicitly give write permissions to Azure disk image, since permissions are no longer dropped on upload --------- Signed-off-by: Daniel Weiße <dw@edgeless.systems>
72 lines
2.1 KiB
YAML
72 lines
2.1 KiB
YAML
name: Upload artifact
|
|
description: Upload an encrypted zip archive as a github artifact.
|
|
|
|
inputs:
|
|
path:
|
|
description: 'The path(s) that should be uploaded. Paths may contain globs. Only the final component of a path is uploaded.'
|
|
required: true
|
|
name:
|
|
description: 'The name of the artifact.'
|
|
required: true
|
|
retention-days:
|
|
description: 'How long the artifact should be retained for.'
|
|
default: 60
|
|
encryptionSecret:
|
|
description: 'The secret to use for encrypting the files.'
|
|
required: true
|
|
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Install zip
|
|
uses: ./.github/actions/setup_bazel_nix
|
|
with:
|
|
nixTools: |
|
|
zip
|
|
|
|
- name: Create temporary directory
|
|
id: tempdir
|
|
shell: bash
|
|
run: echo "directory=$(mktemp -d)" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Create archive
|
|
shell: bash
|
|
run: |
|
|
shopt -s extglob
|
|
|
|
paths="${{ inputs.path }}"
|
|
paths=${paths%$'\n'} # Remove trailing newline
|
|
|
|
# Check if any file matches the given pattern(s).
|
|
something_exists=false
|
|
for pattern in ${paths}
|
|
do
|
|
if compgen -G "${pattern}" > /dev/null; then
|
|
something_exists=true
|
|
fi
|
|
done
|
|
|
|
# Create an archive if files exist.
|
|
# Don't create an archive file if no files are found
|
|
# and warn.
|
|
if ! ${something_exists}
|
|
then
|
|
echo "::warning:: No files/directories found with the provided path(s): ${paths}. No artifact will be uploaded."
|
|
exit 0
|
|
fi
|
|
|
|
for target in ${paths}
|
|
do
|
|
pushd "$(dirname "${target}")" || exit 1
|
|
zip -e -P '${{ inputs.encryptionSecret }}' -r "${{ steps.tempdir.outputs.directory }}/archive.zip" "$(basename "${target}")"
|
|
popd || exit 1
|
|
done
|
|
|
|
- name: Upload archive as artifact
|
|
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
|
|
with:
|
|
name: ${{ inputs.name }}
|
|
path: ${{ steps.tempdir.outputs.directory }}/archive.zip
|
|
retention-days: ${{ inputs.retention-days }}
|
|
if-no-files-found: ignore
|