mirror of
https://github.com/ButlerLogic/action-autotag.git
synced 2024-11-10 02:11:08 +07:00
Cleanup and shift to using core.warning instead of console logs.
This commit is contained in:
parent
e8fe08c417
commit
651af18eed
46
lib/main.js
46
lib/main.js
@ -21,12 +21,17 @@ async function run() {
|
||||
|
||||
core.debug(` Working Directory: ${process.env.GITHUB_WORKSPACE}:\n${dir}`)
|
||||
|
||||
if (!process.env.hasOwnProperty('INPUT_GITHUB_TOKEN') || process.env.INPUT_GITHUB_TOKEN.trim().length === 0) {
|
||||
if (!process.env.hasOwnProperty('GITHUB_TOKEN')) {
|
||||
if (!process.env.hasOwnProperty('GITHUB_TOKEN')) {
|
||||
const gh_token = core.getInput('GITHUB_TOKEN', { required: true })
|
||||
|
||||
if (!gh_token) {
|
||||
core.setFailed('Invalid or missing GITHUB_TOKEN.')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
core.warning('Using `with:\n\tGITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}` is deprecated. See README for new syntax.')
|
||||
process.env.GITHUB_TOKEN = gh_token
|
||||
}
|
||||
|
||||
const pkg_root = core.getInput('package_root', { required: false })
|
||||
const pkgfile = path.join(process.env.GITHUB_WORKSPACE, pkg_root, 'package.json')
|
||||
@ -39,37 +44,8 @@ async function run() {
|
||||
core.setOutput('version', pkg.version)
|
||||
core.debug(` Detected version ${pkg.version}`)
|
||||
|
||||
// core.debug(` Available environment variables:\n -> ${Object.keys(process.env).map(i => i + ' :: ' + process.env[i]).join('\n -> ')}`)
|
||||
|
||||
// let version = ""
|
||||
|
||||
// if (!process.env.hasOwnProperty('INPUT_VERSION') || process.env.INPUT_VERSION.trim().length === 0) {
|
||||
// let dir = fs.readdirSync(path.resolve(process.env.GITHUB_WORKSPACE), { withFileTypes: true }).map(entry => {
|
||||
// return `${entry.isDirectory() ? '> ' : ' - '}${entry.name}`
|
||||
// }).join('\n')
|
||||
|
||||
// core.debug(` Working Directory: ${process.env.GITHUB_WORKSPACE}:\n${dir}`)
|
||||
|
||||
// const pkg_root = core.getInput('package_root', { required: false })
|
||||
// let pkgfile = path.join(process.env.GITHUB_WORKSPACE, pkg_root, 'package.json')
|
||||
|
||||
// if (!fs.existsSync(pkgfile)) {
|
||||
// core.setFailed('package.json does not exist.')
|
||||
// return
|
||||
// }
|
||||
|
||||
// let pkg = require(pkgfile)
|
||||
// version = pkg.version
|
||||
// } else {
|
||||
// version = process.env.INPUT_VERSION.trim()
|
||||
// }
|
||||
|
||||
// core.setOutput('version', version)
|
||||
// core.debug(` Detected version ${version}`)
|
||||
|
||||
|
||||
// Check for existing tag
|
||||
const git = new github.GitHub(process.env.INPUT_GITHUB_TOKEN || process.env.GITHUB_TOKEN)
|
||||
const git = new github.GitHub(process.env.GITHUB_TOKEN)
|
||||
const owner = process.env.GITHUB_ACTOR
|
||||
const repo = process.env.GITHUB_REPOSITORY.split('/').pop()
|
||||
|
||||
@ -94,7 +70,7 @@ async function run() {
|
||||
// Check for existance of tag and abort (short circuit) if it already exists.
|
||||
for (let tag of tags.data) {
|
||||
if (tag.name === getTagName(pkg.version)) {
|
||||
console.log(`"${tag.name.trim()}" tag already exists.` + os.EOL)
|
||||
core.warning(`"${tag.name.trim()}" tag already exists.` + os.EOL)
|
||||
core.setOutput('tagname', '')
|
||||
return
|
||||
}
|
||||
@ -127,7 +103,7 @@ async function run() {
|
||||
)
|
||||
.join('\n')
|
||||
} catch (e) {
|
||||
console.log('Failed to generate changelog from commits: ' + e.message + os.EOL)
|
||||
core.warning('Failed to generate changelog from commits: ' + e.message + os.EOL)
|
||||
tagMsg = tagName
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user