Skip to content

Commit 7eb82bc

Browse files
authored
implement feature #616 (#628)
* add outputs variable 'downloaded_files' * make all files can get by indexer * use dot '.' to access array member instead of [] * add 'f' prefix * build dist/index.js * use '_' to access files array member * add outputs description * remove outputs like 'downloaded_file_*' * try fix build error in example expression * Fix typo, move usage instructions to README
1 parent 8232914 commit 7eb82bc

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ jobs:
8080
echo ${{steps.download-private.outputs.tag_name}}
8181
else echo "Unable to read output variable from step download-private"; exit 1
8282
fi
83+
84+
echo "Downloaded files:"
85+
echo ${{steps.download-public.outputs.downloaded_files}}

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@ A Github Action to download assets from github release. It can download specifie
6767
> ${{steps.<step-id>.outputs.tag_name}}
6868
> ```
6969

70+
- `downloaded_files` it outputs an array of downloaded files
71+
72+
> It can be used as follows
73+
>
74+
> `${{ fromJson(steps.<step-id>.outputs.downloaded_files)[0] }}`
75+
7076
## Scenarios
7177

7278
### Download asset from the latest release in the current repository

action.yml

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ inputs:
4949
outputs:
5050
tag_name:
5151
description: "The github tag used to download the release"
52+
downloaded_files:
53+
description: "The array of downloaded files, useful when using wildcard '*' to download multiple files."
5254

5355
runs:
5456
using: "node16"

dist/index.js

+4-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/release-downloader.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,21 @@ export class ReleaseDownloader {
4242
)
4343
}
4444

45-
// Set the output variables for use by other actions
46-
core.setOutput("tag_name", ghRelease.tag_name)
47-
4845
const resolvedAssets: DownloadMetaData[] = this.resolveAssets(
4946
ghRelease,
5047
downloadSettings
5148
)
5249

53-
return await this.downloadReleaseAssets(
50+
const result = await this.downloadReleaseAssets(
5451
resolvedAssets,
5552
downloadSettings.outFilePath
5653
)
54+
55+
// Set the output variables for use by other actions
56+
core.setOutput("tag_name", ghRelease.tag_name)
57+
core.setOutput("downloaded_files", result)
58+
59+
return result
5760
}
5861

5962
/**

0 commit comments

Comments
 (0)