Skip to content

Commit 376cde1

Browse files
authored
Introducing --output flag on get-usns action. (#1027)
* removing logging usns * feat: adding usns_output_path flag * fix: using correct flag
1 parent a21af31 commit 376cde1

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

actions/stack/get-usns/action.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: |
66
77
outputs:
88
usns:
9-
description: JSON array of patched USNs
9+
description: JSON array of patched USNs or path to JSON file, if usns_output_path flag is specified
1010

1111
inputs:
1212
feed_url:
@@ -27,6 +27,9 @@ inputs:
2727
distribution:
2828
description: 'Ubuntu distribution of stack (bionic|focal|jammy|noble)'
2929
required: true
30+
usns_output_path:
31+
description: 'Path to output usns JSON file'
32+
required: false
3033

3134
runs:
3235
using: 'docker'
@@ -42,3 +45,5 @@ runs:
4245
- "${{ inputs.packages_filepath }}"
4346
- "--distro"
4447
- "${{ inputs.distribution }}"
48+
- "--output"
49+
- "${{ inputs.usns_output_path }}"

actions/stack/get-usns/entrypoint/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ func main() {
151151
output = []byte(`[]`)
152152
}
153153

154-
fmt.Println("Output: ", string(output))
155154
outputFileName, ok := os.LookupEnv("GITHUB_OUTPUT")
156155
if !ok {
157156
log.Fatal("GITHUB_OUTPUT is not set, see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter")
@@ -161,7 +160,6 @@ func main() {
161160
log.Fatal(err)
162161
}
163162
defer file.Close()
164-
fmt.Fprintf(file, "usns=%s\n", string(output))
165163

166164
if config.Output != "" {
167165
path, err := filepath.Abs(config.Output)
@@ -172,6 +170,8 @@ func main() {
172170
if err != nil {
173171
log.Fatal(err)
174172
}
173+
} else {
174+
fmt.Fprintf(file, "usns=%s\n", string(output))
175175
}
176176
}
177177

0 commit comments

Comments
 (0)