Skip to content

Commit

Permalink
Use new output setter using the correct environment variable
Browse files Browse the repository at this point in the history
  • Loading branch information
sormuras committed Oct 19, 2022
1 parent ea6e8d8 commit e81158a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 0 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,11 @@ runs:
DOWNLOAD=$GITHUB_ACTION_PATH/src/Download.java
if [ ! -z "${{ inputs.uri }}" ]; then
$JAVA \
-DeprecatedSetOutput=true \
-Dinstall-as-version="${{ inputs.install-as-version }}" \
$DOWNLOAD \
${{ inputs.uri }}
else
$JAVA \
-DeprecatedSetOutput=true \
-Dinstall-as-version="${{ inputs.install-as-version }}" \
$DOWNLOAD \
${{ inputs.website }} \
Expand Down
12 changes: 4 additions & 8 deletions src/Download.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,15 @@ Optional<String> findRemoteChecksum(String checksum) throws Exception {
static class GitHub {
/** Sets an action's output parameter. */
static void setOutput(String name, Object value) {
if (Boolean.getBoolean(/*-D*/ "eprecatedSetOutput")) {
System.out.printf("::set-output name=%s::%s%n", name, value);
return;
}
if (name.isBlank() || value.toString().isBlank()) { // implicit null checks included
throw new IllegalArgumentException("name or value are blank: " + name + "=" + value);
}
var githubEnv = System.getenv("GITHUB_ENV");
if (githubEnv == null) {
throw new AssertionError("No such environment variable: GITHUB_ENV");
var githubOutput = System.getenv("GITHUB_OUTPUT");
if (githubOutput == null) {
throw new AssertionError("No such environment variable: GITHUB_OUTPUT");
}
try {
var file = Path.of(githubEnv);
var file = Path.of(githubOutput);
if (file.getParent() != null) Files.createDirectories(file.getParent());
var lines = (name + "=" + value).lines().toList();
if (lines.size() != 1) {
Expand Down

0 comments on commit e81158a

Please sign in to comment.