Skip to content

Commit

Permalink
fix: fix some Changelog CI detail
Browse files Browse the repository at this point in the history
  • Loading branch information
xingoxu committed Sep 23, 2020
1 parent 803a625 commit 155eaa9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
22 changes: 5 additions & 17 deletions .github/workflows/commit-changelog.yml
Expand Up @@ -3,7 +3,9 @@ name: Changelog CI
# Controls when the action will run. Triggers the workflow on a pull request
on:
pull_request:
# types: [opened, reopened]
types: [opened, reopened]
branches:
- master

jobs:
build:
Expand All @@ -12,23 +14,9 @@ jobs:
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0
- name: Install Dependency
run: npm i

- name: Config Internal Git
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
- name: Run Changelog CI & Bump npm version
if: ${{ startsWith(github.event.pull_request.title, 'Release') }}
run: npm run generate-changelog

- name: Copy & Deploy
if: ${{ startsWith(github.event.pull_request.title, 'Release') }}
run: |
git add -A
git commit -m '(Changelog CI) Added Changelog'
git push
- name: Run Changelog CI
run: ./scripts/generate-changelog.sh
12 changes: 12 additions & 0 deletions scripts/generate-changelog.sh
@@ -0,0 +1,12 @@
#!/bin/bash

git checkout ${GITHUB_HEAD_REF}

git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"

npm run generate-changelog

git add -A
git commit -m "(Changelog CI) Added Changelog"
git push -u origin ${GITHUB_HEAD_REF}
4 changes: 3 additions & 1 deletion scripts/generate-changelog.ts
Expand Up @@ -41,7 +41,9 @@ const category = {

commitsArray.forEach((message) => {
let cat: keyof typeof category;
if (message.includes("test")) {
if (/^([\d\.]+)$/.test(message)) {
return;
} else if (message.includes("test")) {
cat = "miscs";
} else if (/(add)|(support)/i.test(message)) {
cat = "features";
Expand Down

0 comments on commit 155eaa9

Please sign in to comment.