Add our own upload-artifact and download-artifact actions.

These compress the artifacts prior to calling the official
`{upload,download}-artifact` actions in order to preserve permissions
and symlinks.

Signed-off-by: Pedro Algarvio <palgarvio@vmware.com>
This commit is contained in:
Pedro Algarvio 2023-02-06 14:20:37 +00:00 committed by Pedro Algarvio
parent 292248f812
commit 9c713f4437
2 changed files with 96 additions and 0 deletions

View file

@ -0,0 +1,39 @@
# This actions was inspired by https://github.com/alehechka/download-tartifact
---
name: Download Tar Artifact
description: >
Download and extract a tar artifact that was previously uploaded in the
workflow by the upload-tartifact action
inputs:
name:
description: Artifact name
required: false
path:
description: Destination path
required: false
archive-name:
description: >
By default `inputs.name`(last resort, `archive`) is what's used to name the archive.
This parameter allows a customizing that archive name. This will allow uploading multiple
archives under the same 'name', like the underlying official action does
without overriding the existing archives.
required: false
runs:
using: composite
steps:
- uses: actions/download-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ inputs.path }}
- shell: bash
working-directory: ${{ inputs.path }}
run: |
tar -xvf ${{ inputs.archive-name || inputs.name || 'archive' }}.tar.gz
- shell: bash
working-directory: ${{ inputs.path }}
run: |
rm -f ${{ inputs.archive-name || inputs.name || 'archive' }}.tar.gz

View file

@ -0,0 +1,57 @@
# This actions was inspired by https://github.com/alehechka/upload-tartifact
---
name: Upload Tar Artifact
description: Compress files with tar prior to artifacting to keep file privileges.
inputs:
name:
description: Artifact name
default: artifact
required: false
path:
description: >
A file, directory or wildcard pattern that describes what to upload.
Note: The path provided will be maintained through tar, so after
download-tartifact, and subfolder structure will remain intact.
required: true
if-no-files-found:
description: >
The desired behavior if no files are found using the provided path.
Available Options:
warn: Output a warning but do not fail the action
error: Fail the action with an error message
ignore: Do not output any warnings or errors, the action does not fail
default: 'warn'
required: false
retention-days:
description: >
Duration after which artifact will expire in days. 0 means using default retention.
Minimum 1 day.
Maximum 90 days unless changed from the repository settings page.
required: false
archive-name:
description: >
By default `archive` is what's used to name the archive. This parameter
allows a customizing that archive name. This will allow uploading multiple
archives under the same 'name', like the underlying official action does
without overriding the existing archives.
required: false
runs:
using: composite
steps:
- shell: bash
run: |
shopt -s globstar || echo "'globstar' not available"
tar -cavf ${{ inputs.archive-name || inputs.name || 'archive' }}.tar.gz ${{ inputs.path }}
- uses: actions/upload-artifact@v3
with:
name: ${{ inputs.name }}
path: ${{ inputs.archive-name || inputs.name || 'archive' }}.tar.gz
if-no-files-found: ${{ inputs.if-no-files-found }}
retention-days: ${{ inputs.retention-days }}
- shell: bash
run: |
rm -f ${{ inputs.archive-name || inputs.name || 'archive' }}.tar.gz