diff --git a/.github/workflows/dep-suggests-matrix-read/action.yml b/.github/workflows/dep-suggests-matrix-read/action.yml index b1a8ed0d3..39e7a7b23 100644 --- a/.github/workflows/dep-suggests-matrix-read/action.yml +++ b/.github/workflows/dep-suggests-matrix-read/action.yml @@ -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 diff --git a/.github/workflows/dep-suggests-matrix/action.R b/.github/workflows/dep-suggests-matrix/action.R index c6a08a5b0..139519403 100644 --- a/.github/workflows/dep-suggests-matrix/action.R +++ b/.github/workflows/dep-suggests-matrix/action.R @@ -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)