Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
only error on actual attempt at using bodyFromFile and reorder a bit …
…for tests
  • Loading branch information
Jacob Bolda committed Feb 6, 2020
1 parent 76860a0 commit c06331b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
19 changes: 11 additions & 8 deletions dist/index.js
Expand Up @@ -7863,16 +7863,19 @@ async function run() {
const tag = tagName.replace('refs/tags/', '');
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', '');
const body = core.getInput('body', { required: false });
const bodyFromFile = core.getInput('bodyFromFile', { required: false });
let bodyFile = null;
try {
bodyFile = fs.readFileSync(bodyFromFile, { encoding: 'utf8' });
} catch (error) {
core.setFailed(error.message);
}
const draft = core.getInput('draft', { required: false }) === 'true';
const prerelease = core.getInput('prerelease', { required: false }) === 'true';

const bodyFromFile = core.getInput('bodyFromFile', { required: false });
let bodyFileContent = null;
if (bodyFromFile !== '' && !!bodyFromFile) {
try {
bodyFileContent = fs.readFileSync(bodyFromFile, { encoding: 'utf8' });
} catch (error) {
core.setFailed(error.message);
}
}

// Create a release
// API Documentation: https://developer.github.com/v3/repos/releases/#create-a-release
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-create-release
Expand All @@ -7881,7 +7884,7 @@ async function run() {
repo,
tag_name: tag,
name: releaseName,
body: bodyFile || body,
body: bodyFileContent || body,
draft,
prerelease
});
Expand Down
19 changes: 11 additions & 8 deletions src/create-release.js
Expand Up @@ -17,16 +17,19 @@ async function run() {
const tag = tagName.replace('refs/tags/', '');
const releaseName = core.getInput('release_name', { required: true }).replace('refs/tags/', '');
const body = core.getInput('body', { required: false });
const bodyFromFile = core.getInput('bodyFromFile', { required: false });
let bodyFile = null;
try {
bodyFile = fs.readFileSync(bodyFromFile, { encoding: 'utf8' });
} catch (error) {
core.setFailed(error.message);
}
const draft = core.getInput('draft', { required: false }) === 'true';
const prerelease = core.getInput('prerelease', { required: false }) === 'true';

const bodyFromFile = core.getInput('bodyFromFile', { required: false });
let bodyFileContent = null;
if (bodyFromFile !== '' && !!bodyFromFile) {
try {
bodyFileContent = fs.readFileSync(bodyFromFile, { encoding: 'utf8' });
} catch (error) {
core.setFailed(error.message);
}
}

// Create a release
// API Documentation: https://developer.github.com/v3/repos/releases/#create-a-release
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-create-release
Expand All @@ -35,7 +38,7 @@ async function run() {
repo,
tag_name: tag,
name: releaseName,
body: bodyFile || body,
body: bodyFileContent || body,
draft,
prerelease
});
Expand Down

0 comments on commit c06331b

Please sign in to comment.