From 1b0417032a879685f08952bdd927ad3015219aee Mon Sep 17 00:00:00 2001
From: Bryan Clark <clarkbw@github.com>
Date: Thu, 28 Nov 2019 09:52:58 -0800
Subject: [PATCH] Move auth to the bottom of setup

---
 src/setup-java.ts | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/setup-java.ts b/src/setup-java.ts
index 9e52f9b..99026e3 100644
--- a/src/setup-java.ts
+++ b/src/setup-java.ts
@@ -15,13 +15,16 @@ async function run() {
 
     await installer.getJava(version, arch, jdkFile, javaPackage);
 
+    const matchersPath = path.join(__dirname, '..', '.github');
+    console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
+
     const username = core.getInput('username', {required: false});
     const password = core.getInput('password', {required: false});
 
-    await auth.configAuthentication(username, password);
+    if (username && password) {
+      await auth.configAuthentication(username, password);
+    }
 
-    const matchersPath = path.join(__dirname, '..', '.github');
-    console.log(`##[add-matcher]${path.join(matchersPath, 'java.json')}`);
   } catch (error) {
     core.setFailed(error.message);
   }