Skip to content

Commit

Permalink
Add extra outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrekelmans committed Oct 6, 2020
1 parent e010d75 commit a3761d2
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 11 deletions.
12 changes: 11 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@ description: 'Get the upload URL for a release for a tag in your repository'
author: 'GitHub'
outputs:
id:
description: 'The ID of the Release'
description: 'The ID of the release'
html_url:
description: 'The URL users can navigate to in order to view the release'
upload_url:
description: 'The URL for uploading assets to the release'
tag_name:
description: 'The git tag associated with the release.'
name:
description: 'The name of the release'
body:
description: 'The body of the release'
draft:
description: 'Whether this release is marked as a draft or not'
prerelease:
description: 'Whether this release is marked as a pre-release or not'
runs:
using: 'node12'
main: 'dist/index.js'
Expand Down
21 changes: 16 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4168,6 +4168,12 @@ function convertBody(buffer, headers) {
// html4
if (!res && str) {
res = /<meta[\s]+?http-equiv=(['"])content-type\1[\s]+?content=(['"])(.+?)\2/i.exec(str);
if (!res) {
res = /<meta[\s]+?content=(['"])(.+?)\1[\s]+?http-equiv=(['"])content-type\3/i.exec(str);
if (res) {
res.pop(); // drop last quote
}
}

if (res) {
res = /charset=(.*)/i.exec(res.pop());
Expand Down Expand Up @@ -5175,7 +5181,7 @@ function fetch(url, opts) {
// HTTP fetch step 5.5
switch (request.redirect) {
case 'error':
reject(new FetchError(`redirect mode is set to error: ${request.url}`, 'no-redirect'));
reject(new FetchError(`uri requested responds with a redirect, redirect mode is set to error: ${request.url}`, 'no-redirect'));
finalize();
return;
case 'manual':
Expand Down Expand Up @@ -5214,7 +5220,8 @@ function fetch(url, opts) {
method: request.method,
body: request.body,
signal: request.signal,
timeout: request.timeout
timeout: request.timeout,
size: request.size
};

// HTTP-redirect fetch step 9
Expand Down Expand Up @@ -24839,16 +24846,20 @@ async function run() {

// Get the ID, html_url, and upload URL for the created Release from the response
const {
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl }
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl, name: name, body: body, draft: draft, prerelease: prerelease }
} = getReleaseResponse;

console.log(`Got release info: '${releaseId}', '${htmlUrl}', '${uploadUrl}'`);
console.log(`Got release info: '${releaseId}', '${htmlUrl}', '${uploadUrl}', '${name}', '${draft}', '${prerelease}', '${body}'`);

// Set the output variables for use by other actions: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
core.setOutput("id", releaseId.toString());
core.setOutput("html_url", htmlUrl);
core.setOutput("upload_url", uploadUrl);
core.setOutput("tag_name", tag);
core.setOutput("name", name);
core.setOutput("body", body);
core.setOutput("draft", draft);
core.setOutput("prerelease", prerelease);
} catch (error) {
console.log(error);
core.setFailed(error.message);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "get-release",
"version": "1.0.0",
"description": "Get the upload URL for a release",
"description": "Get github release information",
"main": "dist/index.js",
"scripts": {
"lint": "eslint 'src/**.js' 'tests/**.js' --fix",
Expand Down
12 changes: 8 additions & 4 deletions src/get-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,22 @@ async function run() {
tag
});

// Get the ID, html_url, and upload URL for the created Release from the response
// Get the outputs for the created release from the response
const {
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl }
data: { id: releaseId, html_url: htmlUrl, upload_url: uploadUrl, name: name, body: body, draft: draft, prerelease: prerelease }
} = getReleaseResponse;

console.log(`Got release info: '${releaseId}', '${htmlUrl}', '${uploadUrl}'`);
console.log(`Got release info: '${releaseId}', '${htmlUrl}', '${uploadUrl}', '${name}', '${draft}', '${prerelease}', '${body}'`);

// Set the output variables for use by other actions: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
core.setOutput("id", releaseId.toString());
core.setOutput("html_url", htmlUrl);
core.setOutput("upload_url", uploadUrl);
core.setOutput("tag_name", tag);
core.setOutput("name", name);
core.setOutput("body", body);
core.setOutput("draft", draft);
core.setOutput("prerelease", prerelease);
} catch (error) {
console.log(error);
core.setFailed(error.message);
Expand Down

0 comments on commit a3761d2

Please sign in to comment.