Skip to content

Commit

Permalink
ci: Fix edge case of no suggested packages
Browse files Browse the repository at this point in the history
  • Loading branch information
krlmlr committed Aug 10, 2024
1 parent 6d4c3c7 commit 92ef801
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/dep-suggests-matrix-read/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ runs:

- id: set-matrix
run: |
matrix=$(cat .github/dep-suggests-matrix.json || echo '{"package":[]}')
echo $matrix | jq .
echo $matrix | json2yaml
# Empty contents if no suggested packages
matrix=$(cat .github/dep-suggests-matrix.json || true)
if [ -n "$matrix" ]; then
echo $matrix | jq .
echo $matrix | json2yaml
fi
echo "matrix=$matrix" | tee -a $GITHUB_OUTPUT
shell: bash
15 changes: 10 additions & 5 deletions .github/workflows/dep-suggests-matrix/action.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ if (Sys.getenv("GITHUB_BASE_REF") != "") {
packages <- get_deps()
}

json <- paste0(
'{"package":[',
if (length(packages) > 0) paste0('"', packages, '"', collapse = ","),
']}'
)
if (length(packages) > 0) {
json <- paste0(
'{"package":[',
paste0('"', packages, '"', collapse = ","),
']}'
)
} else {
json <- character()
}

writeLines(json, ".github/dep-suggests-matrix.json")
writeLines(json)

0 comments on commit 92ef801

Please sign in to comment.