Skip to content

Commit 039c329

Browse files
Merge pull request #199 from technote-space/release/v0.7.4
Release/v0.7.4
2 parents 1c95225 + 99828e1 commit 039c329

File tree

7 files changed

+70
-51
lines changed

7 files changed

+70
-51
lines changed

.github/workflows/pr_opened.yml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
on:
2-
pull_request:
3-
types: [opened]
4-
name: Pull Request opened
5-
jobs:
6-
assignToProject:
7-
name: Assign PullRequest to Project
8-
runs-on: ubuntu-latest
9-
steps:
10-
- name: Assign PullRequest to Project
11-
uses: alex-page/[email protected]
12-
with:
13-
project: Backlog
14-
column: To do
15-
repo-token: ${{ secrets.GITHUB_TOKEN }}
16-
17-
assignAuthor:
18-
name: Assign author to PR
19-
runs-on: ubuntu-latest
20-
steps:
21-
- name: Assign Author to PR
22-
uses: technote-space/assign-author@v1
23-
with:
24-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25-
26-
addLabelsByBranch:
27-
name: PR Labeler
28-
runs-on: ubuntu-latest
29-
steps:
30-
- name: PR Labeler
31-
uses: technote-fork/pr-labeler-action@master
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1+
on:
2+
pull_request:
3+
types: [opened]
4+
name: Pull Request opened
5+
jobs:
6+
assignToProject:
7+
name: Assign PullRequest to Project
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Assign PullRequest to Project
11+
uses: alex-page/[email protected]
12+
with:
13+
project: Backlog
14+
column: To do
15+
repo-token: ${{ secrets.GITHUB_TOKEN }}
16+
17+
assignAuthor:
18+
name: Assign author to PR
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Assign Author to PR
22+
uses: technote-space/assign-author@v1
23+
with:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
26+
addLabelsByBranch:
27+
name: PR Labeler
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: PR Labeler
31+
uses: technote-fork/pr-labeler-action@gh-actions
32+
with:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

__tests__/git-helper.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('GitHelper', () => {
4343
});
4444

4545
it('should get current branch name', async() => {
46-
setChildProcessParams({stdout: ' master\n* test-branch\n develop'});
46+
setChildProcessParams({stdout: 'test-branch'});
4747
expect(await helper.getCurrentBranchName(workDir)).toBe('test-branch');
4848
});
4949
});

__tests__/utils.test.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import path from 'path';
33
import { testEnv, getContext, testFs } from '@technote-space/github-action-test-helper';
44
import { Utils } from '../src';
55

6-
const {getWorkspace, getActor, escapeRegExp, getRegExp, getPrefixRegExp, getSuffixRegExp, useNpm, versionCompare} = Utils;
7-
const {isSemanticVersioningTagName, isPrRef, getPrMergeRef, getBoolValue, replaceAll, getPrHeadRef, arrayChunk} = Utils;
8-
const {getBranch, getRefForUpdate, uniqueArray, getBuildInfo, split, getArrayInput, generateNewPatchVersion, sleep} = Utils;
6+
const {getWorkspace, getActor, escapeRegExp, getRegExp, getPrefixRegExp, getSuffixRegExp, useNpm, versionCompare} = Utils;
7+
const {isSemanticVersioningTagName, isPrRef, getPrMergeRef, getBoolValue, replaceAll, getPrHeadRef, arrayChunk, sleep} = Utils;
8+
const {getBranch, getRefForUpdate, uniqueArray, getBuildInfo, split, getArrayInput, generateNewPatchVersion, getPrBranch} = Utils;
99

1010
jest.useFakeTimers();
1111

@@ -219,6 +219,24 @@ describe('getBranch', () => {
219219
});
220220
});
221221

222+
describe('getPrBranch', () => {
223+
it('should get pr branch', () => {
224+
expect(getPrBranch(getContext({
225+
payload: {
226+
'pull_request': {
227+
head: {
228+
ref: 'test/abc',
229+
},
230+
},
231+
},
232+
}))).toBe('test/abc');
233+
});
234+
235+
it('should not get pr branch', () => {
236+
expect(getPrBranch(getContext({}))).toBe('');
237+
});
238+
});
239+
222240
describe('getRefForUpdate', () => {
223241
// https://github.com/octokit/rest.js/issues/1308#issuecomment-480532468
224242
it('should get ref for update', () => {

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@technote-space/github-action-helper",
3-
"version": "0.7.3",
3+
"version": "0.7.4",
44
"description": "Helper to filter GitHub Action.",
55
"author": "Technote <[email protected]> (https://technote.space)",
66
"license": "MIT",
@@ -28,7 +28,7 @@
2828
"sprintf-js": "^1.1.2"
2929
},
3030
"devDependencies": {
31-
"@technote-space/github-action-test-helper": "^0.1.1",
31+
"@technote-space/github-action-test-helper": "^0.1.2",
3232
"@types/jest": "^24.9.0",
3333
"@types/node": "^13.1.8",
3434
"@typescript-eslint/eslint-plugin": "^2.16.0",

src/git-helper.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ export default class GitHelper {
125125
if (!isCloned(workDir)) {
126126
return '';
127127
}
128-
// eslint-disable-next-line no-magic-numbers
129-
return (await this.runCommand(workDir, {command: 'git branch', args: ['-a']}))[0].stdout.find(branch => branch.startsWith('*'))?.slice(2).trim() ?? '';
128+
return (await this.runCommand(workDir, {command: 'git rev-parse', args: ['--abbrev-ref', 'HEAD']}))[0].stdout[0]?.trim() ?? '';
130129
};
131130

132131
/**

src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ export const getBranch = (ref: string | Context, defaultIsEmpty = true): string
5252
)
5353
);
5454

55+
export const getPrBranch = (context: Context): string => context.payload.pull_request?.head.ref ?? '';
56+
5557
export const getAccessToken = (required: boolean): string => getInput('GITHUB_TOKEN', {required});
5658

5759
export const getActor = (): string => process.env.GITHUB_ACTOR || '';

yarn.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,16 +360,16 @@
360360
universal-user-agent "^4.0.0"
361361

362362
"@octokit/types@^2.0.0":
363-
version "2.0.2"
364-
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.0.2.tgz#0888497f5a664e28b0449731d5e88e19b2a74f90"
365-
integrity sha512-StASIL2lgT3TRjxv17z9pAqbnI7HGu9DrJlg3sEBFfCLaMEqp+O3IQPUF6EZtQ4xkAu2ml6kMBBCtGxjvmtmuQ==
363+
version "2.1.0"
364+
resolved "https://registry.yarnpkg.com/@octokit/types/-/types-2.1.0.tgz#fe3ea39ed7d20ec06954a9314d4f17aa93e033a3"
365+
integrity sha512-n1GUYFgKm5glcy0E+U5jnqAFY2p04rnK4A0YhuM70C7Vm9Vyx+xYwd/WOTEr8nUJcbPSR/XL+/26+rirY6jJQA==
366366
dependencies:
367367
"@types/node" ">= 8"
368368

369-
"@technote-space/github-action-test-helper@^0.1.1":
370-
version "0.1.1"
371-
resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.1.1.tgz#6480b5516cc7e9291685226caa31f58671e3e11f"
372-
integrity sha512-K6ebxvzskzjTZeK75Ymbg0F0CyZRLMAewjHiiWguyn1HfIKGllJxLhS0TSApJo3092+VsDSiPCYTeL+nQTMEVg==
369+
"@technote-space/github-action-test-helper@^0.1.2":
370+
version "0.1.2"
371+
resolved "https://registry.yarnpkg.com/@technote-space/github-action-test-helper/-/github-action-test-helper-0.1.2.tgz#50d37d9487da0a41650aa645c75fce71711ec55d"
372+
integrity sha512-uA1fjmcWP/x9o1RA/D6cXZtptanTXEBbe1DLC1Ia/cO42/IeLQXvmJ7ICogWVMgA9OG5xWFqolGdc3ygXF1qZg==
373373
dependencies:
374374
"@actions/github" "^2.0.1"
375375
js-yaml "^3.13.1"
@@ -1193,9 +1193,9 @@ error-ex@^1.3.1:
11931193
is-arrayish "^0.2.1"
11941194

11951195
es-abstract@^1.17.0-next.1, es-abstract@^1.17.2:
1196-
version "1.17.2"
1197-
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.2.tgz#965b10af56597b631da15872c17a405e86c1fd46"
1198-
integrity sha512-YoKuru3Lyoy7yVTBSH2j7UxTqe/je3dWAruC0sHvZX1GNd5zX8SSLvQqEgO9b3Ex8IW+goFI9arEEsFIbulhOw==
1196+
version "1.17.3"
1197+
resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.3.tgz#d921ff5889a3664921094bb13aaf0dfd11818578"
1198+
integrity sha512-AwiVPKf3sKGMoWtFw0J7Y4MTZ4Iek67k4COWOwHqS8B9TOZ71DCfcoBmdamy8Y6mj4MDz0+VNUpC2HKHFHA3pg==
11991199
dependencies:
12001200
es-to-primitive "^1.2.1"
12011201
function-bind "^1.1.1"

0 commit comments

Comments
 (0)