Skip to content

Commit

Permalink
fix git log error
Browse files Browse the repository at this point in the history
  • Loading branch information
xingoxu committed Sep 18, 2020
1 parent 9e1afac commit 62826c1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/commit-changelog.yml
Expand Up @@ -3,8 +3,7 @@ name: Changelog CI
# Controls when the action will run. Triggers the workflow on a pull request
on:
pull_request:
branches:
types: [opened, reopened]
# types: [opened, reopened]

jobs:
build:
Expand Down
8 changes: 6 additions & 2 deletions scripts/generate-changelog.ts
Expand Up @@ -6,16 +6,20 @@ const { version: lastVersion } = require("../package.json");
const changeLogPath = resolve(__dirname, "../CHANGELOG.md");

let newVersion = lastVersion;
let latestCommitId = '';

console.log("Gets Release Version from GITHUB_EVENT_PATH");
if (process.env.GITHUB_EVENT_PATH) {
const {
pull_request: { title },
after,
} = require(process.env.GITHUB_EVENT_PATH);

if (/^release/i.test(title))
{
newVersion = (title as string).match(/release ([\d\.]+)/i)[1];
else {
latestCommitId = after;
} else {
console.log("Not target pull request, exiting");
process.exit(0);
}
Expand All @@ -26,7 +30,7 @@ console.log("Bump Version");
execSync(`npm version ${newVersion}`);

const gitLogOutput = execSync(
`git log v${lastVersion}... --format=%s`
`git log v${lastVersion}...${latestCommitId} --format=%s`
).toString("utf-8");

const commitsArray = gitLogOutput
Expand Down

0 comments on commit 62826c1

Please sign in to comment.