-
Notifications
You must be signed in to change notification settings - Fork 2
/
action.yml
108 lines (98 loc) · 4.62 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
name: 'Tar and Upload a Build Artifact'
description: 'Pack files in a tar archive and upload a build artifact that can be used by subsequent workflow steps'
branding:
icon: 'arrow-up-circle'
color: 'orange'
inputs:
name:
description: 'Artifact name'
default: 'artifact'
path:
description: 'A file, directory or wildcard pattern that describes what to upload'
required: true
directory:
description: 'Change to DIR before performing any operations. This option is order-sensitive, i.e. it affects all optionsthat follow.'
default: '.'
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'
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.
compression-level:
description: >
The level of compression for Zlib to be applied to the artifact archive.
The value can range from 0 to 9:
- 0: No compression
- 1: Best speed
- 6: Default compression (same as GNU Gzip)
- 9: Best compression
Higher levels will result in better compression, but will take longer to complete.
For large files that are not easily compressed, a value of 0 is recommended for significantly faster uploads.
default: '6'
overwrite:
description: >
If true, an artifact with a matching name will be deleted before a new one is uploaded.
If false, the action will fail if an artifact for the given name already exists.
Does not fail if the artifact does not exist.
default: 'false'
outputs:
artifact-id:
description: >
A unique identifier for the artifact that was just uploaded. Empty if the artifact upload failed.
This ID can be used as input to other APIs to download, delete or get more information about an artifact: https://docs.github.com/en/rest/actions/artifacts
value: ${{steps.upload-artifact.outputs.artifact-id}}
artifact-url:
description: >
A download URL for the artifact that was just uploaded. Empty if the artifact upload failed.
This download URL only works for requests Authenticated with GitHub. Anonymous downloads will be prompted to first login.
If an anonymous download URL is needed than a short time restricted URL can be generated using the download artifact API: https://docs.github.com/en/rest/actions/artifacts#download-an-artifact
This URL will be valid for as long as the artifact exists and the workflow run and repository exists. Once an artifact has expired this URL will no longer work.
Common uses cases for such a download URL can be adding download links to artifacts in descriptions or comments on pull requests or issues.
value: ${{steps.upload-artifact.outputs.artifact-url}}
runs:
using: 'composite'
steps:
- name: '📂 prepare path'
id: input_path
shell: 'bash'
run: |
input_path="${{ inputs.path }}"
input_path=${input_path//'\r'/}
input_path=${input_path//$'\n'/' '}
input_path=${input_path%$' '}
echo "input_path=$input_path" >> $GITHUB_OUTPUT
- name: '📦 tar inputs'
shell: 'bash'
run: |
for x in ${{ steps.input_path.outputs.input_path }}; do
# exit the loop if no file matching inputs.path exists
if test -e "$x"; then
# at least one path exists and tar won't be empty
tar -cvf ${{ inputs.name }}.tar -C ${{ inputs.directory }} ${{ steps.input_path.outputs.input_path }} --ignore-failed-read
echo "Adding ${{ steps.input_path.outputs.input_path }} from ${{ inputs.directory }} to ${{ inputs.name }}.tar"
# exit the loop since the tar was created
break
fi
done
test -f ${{ inputs.name }}.tar && echo "${{ inputs.name }}.tar created" || echo "No files found"
- name: '📤 upload artifact'
id: upload-artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.name }}
path: ${{ inputs.name }}.tar
if-no-files-found: ${{ inputs.if-no-files-found }}
retention-days: ${{ inputs.retention-days }}
compression-level: ${{ inputs.compression-level }}
overwrite: ${{ inputs.overwrite }}
- name: '🧹 cleanup'
shell: 'bash'
run: rm -f ${{ inputs.name }}.tar