-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
77 lines (65 loc) · 3.14 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
name: 'Tar and upload a path, preserving permissions'
description: 'Upload a build artifact that can be used by subsequent workflow steps, with permissions preserved.'
author: 'The Browser Company of New York'
inputs:
name:
description: 'The name of the artifact to create.'
default: 'artifact'
path:
description: 'The path to compress and upload.'
required: true
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.
default: 0
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
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.
runs:
using: composite
steps:
- name: Create Tar Archive
id: create-tar
shell: pwsh
run: |
$TempDir = New-TemporaryFile | % { Remove-Item $_; New-Item -ItemType Directory -Path $_ }
$TarFile = Join-Path $TempDir "${{ inputs.name }}.tar"
Write-Output "tar-file=$TarFile" >> $env:GITHUB_OUTPUT
$Tar = if ($IsWindows) { "${env:WINDIR}\System32\tar.exe" } else { "tar" }
if (Test-Path "${{ inputs.path }}" -PathType Leaf) {
# Input is a single file.
$Path = Split-Path "${{ inputs.path }}"
if ($Path -eq "") {
$Path = "."
}
& $Tar cf $TarFile -C $Path (Split-Path -Leaf "${{ inputs.path }}")
} else {
& $Tar cf $TarFile -C "${{ inputs.path }}" .
}
- uses: actions/upload-artifact@v4
id: upload-artifact
with:
name: ${{ inputs.name }}
path: ${{ steps.create-tar.outputs.tar-file }}
retention-days: ${{ inputs.retention-days }}
- name: Delete Temporary Directory
shell: pwsh
run: |
$TempDir = Split-Path -Parent ${{ steps.create-tar.outputs.tar-file }}
Remove-Item -Recurse $TempDir
- name: Export Outputs
shell: pwsh
run: |
Write-Output "artifact-id=${{ steps.upload-artifact.outputs.artifact-id }}" >> $env:GITHUB_OUTPUT
Write-Output "artifact-url=${{ steps.upload-artifact.outputs.artifact-url }}" >> $env:GITHUB_OUTPUT