Skip to content

Commit

Permalink
Merge branch 'master' into fix/console_module
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomchan-cxj authored Dec 19, 2022
2 parents 6fdc19f + 446f5bb commit 3d2b474
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/gh_action_approve_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
uses: navikt/github-app-token-generator@v1
id: get-token
with:
private-key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.ACTION_PRIVATE_KEY }}
app-id: ${{ secrets.ACTION_APP_ID }}
- name: Action
uses: actions/github-script@v6.3.3
env:
Expand Down Expand Up @@ -124,8 +124,8 @@ jobs:
uses: navikt/github-app-token-generator@v1
id: get-token
with:
private-key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.ACTION_PRIVATE_KEY }}
app-id: ${{ secrets.ACTION_APP_ID }}
- name: Action
uses: actions/github-script@v6.3.3
with:
Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/gh_action_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
with:
private-key: ${{ secrets.ACTION_PRIVATE_KEY }}
app-id: ${{ secrets.ACTION_APP_ID }}
- name: Check
- name: Reset
if: "contains(github.event.pull_request.labels.*.name, 'action(squash-merge): failed')"
uses: actions-ecosystem/action-remove-labels@v1.3.0
with:
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
fi
- name: Squash
id: squash
if: ${{ !steps.commitlint.outputs.failed_result }}
if: ${{ !steps.commitlint.outputs.failed_result && github.event.pull_request.user.login != github.event.sender.login }}
env:
GH_TOKEN: ${{ steps.get-token.outputs.token }}
shell: bash {0}
Expand Down Expand Up @@ -102,15 +102,18 @@ jobs:
with:
github-token: ${{ steps.get-token.outputs.token }}
script: |
const { pull_request } = context.payload;
const { pull_request, sender } = context.payload;
const { issues } = github.rest;
const util = require('util');
const os = require('os');
let body;
if (process.env.CHECK_RESULT) {
body = util.format(process.env.FAILED_MESSAGE, 'pull request title does not meet the [Convention Commit](https://conventionalcommits.org/) guideline', process.env.CHECK_RESULT);
} else if (process.env.SQUASH_RESULT) {
body = util.format(process.env.FAILED_MESSAGE, 'auto squash and merge failed', process.env.SQUASH_RESULT);
} else if (pull_request.user.login === sender.login) {
body = util.format(process.env.FAILED_MESSAGE, 'cannot squash and merge your own pull request', `(empty response)`);
}
const p = [];
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh_pr_checks_approval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ jobs:
if: steps.find_comment.outputs.comment-id == ''
uses: navikt/github-app-token-generator@v1
with:
private-key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
app-id: ${{ secrets.BOT_APP_ID }}
- name: Comment
uses: peter-evans/create-or-update-comment@v2
if: steps.get-token.outputs.token != ''
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh_pr_review_notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ jobs:
if: steps.find_comment.outputs.comment-id == '' && steps.parse_workflow_output.outputs.review_state == 'changes_requested'
uses: navikt/github-app-token-generator@v1
with:
private-key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.BOT_APP_KEY }}
app-id: ${{ secrets.BOT_APP_ID }}
- name: Comment
uses: peter-evans/create-or-update-comment@v2
if: steps.get-token.outputs.token != ''
Expand Down
28 changes: 25 additions & 3 deletions commitlint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,29 @@ module.exports = {
],
plugins: ['commitlint-plugin-function-rules'],
rules: {
'header-max-length': [2, 'always', 72],
'function-rules/header-max-length': [
2,
'always',
(parsed) => {
const { header } = parsed;
if (!header) return [false, 'header cannot be empty'];
let prTextIndex = -1;
const regResult = /\s*\(#\w+\)$/.exec(header);
if (regResult && typeof regResult.index === 'number') {
prTextIndex = regResult.index;
console.log(`This commit message header has PR number texts at position ${prTextIndex}, which will be ignored.`);
}
let { length } = header;
if (prTextIndex !== -1) {
length = prTextIndex;
}
const maxLength = 72;
if (length <= maxLength) {
return [true];
}
return [false, `header must not be longer than ${maxLength} characters, current length i ${length}`];
},
],
'header-min-length': [0],
'function-rules/header-min-length': [
2,
Expand All @@ -39,11 +61,11 @@ module.exports = {
const { subject } = parsed;
if (!subject) return [false, 'header subject cannot be empty'];
const { length } = subject;
const minLength = 8;
const minLength = 15;
if (length >= minLength) {
return [true];
}
return [false, `header subject cannot be shorter than ${minLength} characters, current length is ${length}`];
return [false, `header subject must not be shorter than ${minLength} characters, current length is ${length}`];
},
],
'type-enum': [
Expand Down

0 comments on commit 3d2b474

Please sign in to comment.