Skip to content

Commit

Permalink
[#1] git variant needs validations
Browse files Browse the repository at this point in the history
  • Loading branch information
feelform committed Nov 9, 2021
1 parent 350f166 commit b301c79
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 8 additions & 8 deletions .github/actions/markdown-template-engine-action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ const run = async () => {
const templateMarkdownFile = core.getInput('template_markdown_file')
const template = await fs.readFile(templateMarkdownFile, 'utf8')

const version = ReleaseNotes.makeOfMarkdownContents(template).getVersionWithV()
const disableBranch = core.getInput('disable_branch')
if (version && disableBranch.length == 0) {
await git.branch([version])
await git.push('origin', version)
}

let githubRelease = await GithubRelease.make()
if (!githubRelease) {
if (githubRelease) {
const version = ReleaseNotes.makeOfMarkdownContents(template).getVersionWithV()
const disableBranch = core.getInput('disable_branch')
if (version && githubRelease.needsBranch(version) && disableBranch.length == 0) {
await git.branch([version])
await git.push('origin', version)
}
} else {
githubRelease = await GithubRelease.makeByLatestGithubReleaseNotes()
}
let engine = new TemplateEngine(template)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class GithubRelease {

static async make() {
const payload = github.context.payload['client_payload']
if (!payload) {
return
}
const { data } = await axios.get(`https://api.github.com/users/${payload.username}`)
return new GithubRelease(payload, { name: data.name, email: `${payload.username}@users.noreply.github.com` })
}
Expand All @@ -43,6 +46,7 @@ class GithubRelease {
this.author = author
this.tagName = payload.release.tag_name
this.htmlURL = payload.release.html_url
this.version = ReleaseNotes.tagName(payload.release.tag_name)
}

getName() {
Expand All @@ -68,6 +72,14 @@ class GithubRelease {
getTagName() {
return this.tagName
}

getVersion() {
return `v${this.version}`
}

needsBranch(other) {
return this.getVersion() !== other
}
}

module.exports = GithubRelease

0 comments on commit b301c79

Please sign in to comment.