diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 45b8626..805d411 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -9,12 +9,12 @@ jobs: operating-system: [ubuntu-latest, windows-latest] steps: - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - - name: Set Node.js 10.x - uses: actions/setup-node@master + - name: Setup Node.js 12.x + uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: npm install run: npm install @@ -40,12 +40,12 @@ jobs: run: | echo "127.0.0.0 registry.npm.js nodejs.org github.com api.github.com download.java.net static.azul.com" | sudo tee -a /etc/hosts - name: Checkout - uses: actions/checkout@master + uses: actions/checkout@v2 - - name: Set Node.js 10.x - uses: actions/setup-node@master + - name: Setup Node.js 12.x + uses: actions/setup-node@v1 with: - node-version: 10.x + node-version: 12.x - name: npm install run: npm install diff --git a/dist/index.js b/dist/index.js index 12c71d3..9663265 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/src/installer.ts b/src/installer.ts index 9cc16a5..cce8fa3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -39,15 +39,28 @@ export async function getJava( } else { let compressedFileExtension = ''; if (!jdkFile) { - core.debug('Downloading Jdk from Azul'); - let http: httpm.HttpClient = new httpm.HttpClient('setup-java'); - let contents = await ( - await http.get('https://static.azul.com/zulu/bin/') - ).readBody(); - let refs = contents.match(//gi) || []; + core.debug('Downloading JDK from Azul'); + const http = new httpm.HttpClient('setup-java', undefined, { + allowRetries: true, + maxRetries: 3 + }); + const url = 'https://static.azul.com/zulu/bin/'; + const response = await http.get(url); + const statusCode = response.message.statusCode || 0; + if (statusCode < 200 || statusCode > 299) { + let body = ''; + try { + body = await response.readBody(); + } catch (err) { + core.debug(`Unable to read body: ${err.message}`); + } + const message = `Unexpected HTTP status code '${response.message.statusCode}' when retrieving versions from '${url}'. ${body}`.trim(); + throw new Error(message); + } + const contents = await response.readBody(); + const refs = contents.match(//gi) || []; const downloadInfo = getDownloadInfo(refs, version, javaPackage); - jdkFile = await tc.downloadTool(downloadInfo.url); version = downloadInfo.version; compressedFileExtension = IS_WINDOWS ? '.zip' : '.tar.gz';