Skip to content

Commit

Permalink
Import only required core methods from action - works around actions/…
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Oct 14, 2022
1 parent 3e31558 commit 0ac54d5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
42 changes: 21 additions & 21 deletions dist/index.js
Expand Up @@ -19241,11 +19241,11 @@ var require_mode = __commonJS({
var require_isexe = __commonJS({
"node_modules/isexe/index.js"(exports, module) {
var fs = __require("fs");
var core2;
var core;
if (process.platform === "win32" || global.TESTING_WINDOWS) {
core2 = require_windows();
core = require_windows();
} else {
core2 = require_mode();
core = require_mode();
}
module.exports = isexe;
isexe.sync = sync;
Expand All @@ -19268,7 +19268,7 @@ var require_isexe = __commonJS({
});
});
}
core2(path, options || {}, function(er, is) {
core(path, options || {}, function(er, is) {
if (er) {
if (er.code === "EACCES" || options && options.ignoreErrors) {
er = null;
Expand All @@ -19280,7 +19280,7 @@ var require_isexe = __commonJS({
}
function sync(path, options) {
try {
return core2.sync(path, options || {});
return core.sync(path, options || {});
} catch (er) {
if (options && options.ignoreErrors || er.code === "EACCES") {
return false;
Expand Down Expand Up @@ -24641,7 +24641,7 @@ var require_github = __commonJS({
});

// index.js
var core = __toESM(require_core(), 1);
var import_core = __toESM(require_core(), 1);
var import_github = __toESM(require_github(), 1);
async function run() {
try {
Expand All @@ -24651,7 +24651,7 @@ async function run() {
const tag = process.env.TAG || process.env.INPUT_TAG || "";
const deleteOrphan = (process.env.INPUT_DELETE_ORPHAN_TAG || "").trim().toLowerCase() === "true";
if (!id && !tag) {
core.setFailed("At least one of the following inputs must be defined: release_id or tag.");
(0, import_core.setFailed)("At least one of the following inputs must be defined: release_id or tag.");
return;
}
let data;
Expand All @@ -24663,7 +24663,7 @@ async function run() {
tag
});
} catch (e) {
core.warning(`Could not retrieve release for ${tag}: ${e.message}`);
(0, import_core.warning)(`Could not retrieve release for ${tag}: ${e.message}`);
}
if (!data) {
if (deleteOrphan) {
Expand All @@ -24673,11 +24673,11 @@ async function run() {
ref: `tags/${tag}`
});
if (deleteTagResponse) {
core.notice(`Removed ${tag}, even though there was no associated release.`);
(0, import_core.notice)(`Removed ${tag}, even though there was no associated release.`);
return;
}
}
core.setFailed(`Tag "${tag}" was not found or a release ID is not associated with it.`);
(0, import_core.setFailed)(`Tag "${tag}" was not found or a release ID is not associated with it.`);
return;
}
data = data.data;
Expand All @@ -24688,32 +24688,32 @@ async function run() {
release_id: id
});
if (!data) {
core.debug(JSON.stringify(data, null, 2));
core.setFailed(`Release "${id}" was not found.`);
(0, import_core.debug)(JSON.stringify(data, null, 2));
(0, import_core.setFailed)(`Release "${id}" was not found.`);
return;
}
data = data.data;
}
core.debug(JSON.stringify(data, null, 2));
core.debug(`Removing release ${data.id}`);
(0, import_core.debug)(JSON.stringify(data, null, 2));
(0, import_core.debug)(`Removing release ${data.id}`);
const response = await github.repos.deleteRelease({
owner,
repo,
release_id: data.id
});
core.debug(JSON.stringify(response, null, 2));
core.debug(`Removing reference: tags/${data.tag_name}`);
(0, import_core.debug)(JSON.stringify(response, null, 2));
(0, import_core.debug)(`Removing reference: tags/${data.tag_name}`);
const tagresponse = await github.git.deleteRef({
owner,
repo,
ref: `tags/${data.tag_name}`
});
core.debug(JSON.stringify(tagresponse, null, 2));
core.setOutput("release_id", data.id.toString());
core.setOutput("tag", data.tag_name.toString());
(0, import_core.debug)(JSON.stringify(tagresponse, null, 2));
(0, import_core.setOutput)("release_id", data.id.toString());
(0, import_core.setOutput)("tag", data.tag_name.toString());
} catch (e) {
core.warning(e.stack);
core.setFailed(e.message);
(0, import_core.warning)(e.stack);
(0, import_core.setFailed)(e.message);
}
}
run();
Expand Down
36 changes: 18 additions & 18 deletions index.js
@@ -1,4 +1,4 @@
import * as core from '@actions/core'
import { setFailed, warning, notice, debug, setOutput } from '@actions/core'
import { GitHub, context } from '@actions/github'

async function run () {
Expand All @@ -10,12 +10,12 @@ async function run () {
const { owner, repo } = context.repo

// Get the inputs from the workflow file: https://github.com/actions/toolkit/tree/master/packages/core#inputsoutputs
const id = process.env.RELEASE_ID || process.env.INPUT_RELEASE_ID || '' // core.getInput('release_id', { required: false })
const tag = process.env.TAG || process.env.INPUT_TAG || '' // core.getInput('tag', { required: false })
const id = process.env.RELEASE_ID || process.env.INPUT_RELEASE_ID || '' // getInput('release_id', { required: false })
const tag = process.env.TAG || process.env.INPUT_TAG || '' // getInput('tag', { required: false })
const deleteOrphan = (process.env.INPUT_DELETE_ORPHAN_TAG || '').trim().toLowerCase() === 'true'

if (!id && !tag) {
core.setFailed('At least one of the following inputs must be defined: release_id or tag.')
setFailed('At least one of the following inputs must be defined: release_id or tag.')
return
}

Expand All @@ -29,7 +29,7 @@ async function run () {
tag
})
} catch (e) {
core.warning(`Could not retrieve release for ${tag}: ${e.message}`)
warning(`Could not retrieve release for ${tag}: ${e.message}`)
}

if (!data) {
Expand All @@ -41,12 +41,12 @@ async function run () {
})

if (deleteTagResponse) {
core.notice(`Removed ${tag}, even though there was no associated release.`)
notice(`Removed ${tag}, even though there was no associated release.`)
return
}
}

core.setFailed(`Tag "${tag}" was not found or a release ID is not associated with it.`)
setFailed(`Tag "${tag}" was not found or a release ID is not associated with it.`)
return
}

Expand All @@ -59,41 +59,41 @@ async function run () {
})

if (!data) {
core.debug(JSON.stringify(data, null, 2))
core.setFailed(`Release "${id}" was not found.`)
debug(JSON.stringify(data, null, 2))
setFailed(`Release "${id}" was not found.`)
return
}

data = data.data
}

core.debug(JSON.stringify(data, null, 2))
debug(JSON.stringify(data, null, 2))

// API Documentation: https://developer.github.com/v3/repos/releases/#delete-a-release
// Octokit Documentation: https://octokit.github.io/rest.js/#octokit-routes-repos-delete-release
core.debug(`Removing release ${data.id}`)
debug(`Removing release ${data.id}`)
const response = await github.repos.deleteRelease({
owner,
repo,
release_id: data.id
})

core.debug(JSON.stringify(response, null, 2))
debug(JSON.stringify(response, null, 2))

// Delete tag reference
core.debug(`Removing reference: tags/${data.tag_name}`)
debug(`Removing reference: tags/${data.tag_name}`)
const tagresponse = await github.git.deleteRef({
owner,
repo,
ref: `tags/${data.tag_name}`
})

core.debug(JSON.stringify(tagresponse, null, 2))
core.setOutput('release_id', data.id.toString())
core.setOutput('tag', data.tag_name.toString())
debug(JSON.stringify(tagresponse, null, 2))
setOutput('release_id', data.id.toString())
setOutput('tag', data.tag_name.toString())
} catch (e) {
core.warning(e.stack)
core.setFailed(e.message)
warning(e.stack)
setFailed(e.message)
}
}

Expand Down

0 comments on commit 0ac54d5

Please sign in to comment.