npm-cli-gh-issue-preparator 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +0 -0
- package/.eslintrc.cjs +65 -0
- package/.github/CODEOWNERS +2 -0
- package/.github/workflows/commit-lint.yml +52 -0
- package/.github/workflows/configs/commitlint.config.js +27 -0
- package/.github/workflows/create-pr.yml +66 -0
- package/.github/workflows/empty-format-test-job.yml +28 -0
- package/.github/workflows/format.yml +25 -0
- package/.github/workflows/publish.yml +47 -0
- package/.github/workflows/test.yml +38 -0
- package/.github/workflows/umino-project.yml +191 -0
- package/.prettierignore +22 -0
- package/.prettierrc +5 -0
- package/CHANGELOG.md +27 -0
- package/CONTRIBUTING.md +107 -0
- package/README.md +49 -0
- package/bin/adapter/entry-points/cli/index.js +72 -0
- package/bin/adapter/entry-points/cli/index.js.map +1 -0
- package/bin/adapter/repositories/GitHubIssueRepository.js +340 -0
- package/bin/adapter/repositories/GitHubIssueRepository.js.map +1 -0
- package/bin/adapter/repositories/GitHubProjectRepository.js +123 -0
- package/bin/adapter/repositories/GitHubProjectRepository.js.map +1 -0
- package/bin/adapter/repositories/NodeLocalCommandRunner.js +34 -0
- package/bin/adapter/repositories/NodeLocalCommandRunner.js.map +1 -0
- package/bin/domain/entities/Issue.js +3 -0
- package/bin/domain/entities/Issue.js.map +1 -0
- package/bin/domain/entities/Project.js +3 -0
- package/bin/domain/entities/Project.js.map +1 -0
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js +37 -0
- package/bin/domain/usecases/NotifyFinishedIssuePreparationUseCase.js.map +1 -0
- package/bin/domain/usecases/StartPreparationUseCase.js +31 -0
- package/bin/domain/usecases/StartPreparationUseCase.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/IssueRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/IssueRepository.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/LocalCommandRunner.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/LocalCommandRunner.js.map +1 -0
- package/bin/domain/usecases/adapter-interfaces/ProjectRepository.js +3 -0
- package/bin/domain/usecases/adapter-interfaces/ProjectRepository.js.map +1 -0
- package/bin/index.js +6 -0
- package/bin/index.js.map +1 -0
- package/commitlint.config.js +6 -0
- package/jest.config.js +33 -0
- package/package.json +75 -0
- package/renovate.json +37 -0
- package/src/adapter/entry-points/cli/index.integration.test.ts +143 -0
- package/src/adapter/entry-points/cli/index.test.ts +165 -0
- package/src/adapter/entry-points/cli/index.ts +110 -0
- package/src/adapter/repositories/GitHubIssueRepository.integration.test.ts +50 -0
- package/src/adapter/repositories/GitHubIssueRepository.test.ts +996 -0
- package/src/adapter/repositories/GitHubIssueRepository.ts +470 -0
- package/src/adapter/repositories/GitHubProjectRepository.test.ts +252 -0
- package/src/adapter/repositories/GitHubProjectRepository.ts +162 -0
- package/src/adapter/repositories/NodeLocalCommandRunner.test.ts +80 -0
- package/src/adapter/repositories/NodeLocalCommandRunner.ts +37 -0
- package/src/domain/entities/Issue.ts +7 -0
- package/src/domain/entities/Project.ts +7 -0
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.test.ts +109 -0
- package/src/domain/usecases/NotifyFinishedIssuePreparationUseCase.ts +48 -0
- package/src/domain/usecases/StartPreparationUseCase.test.ts +150 -0
- package/src/domain/usecases/StartPreparationUseCase.ts +48 -0
- package/src/domain/usecases/adapter-interfaces/IssueRepository.ts +8 -0
- package/src/domain/usecases/adapter-interfaces/LocalCommandRunner.ts +7 -0
- package/src/domain/usecases/adapter-interfaces/ProjectRepository.ts +5 -0
- package/src/index.test.ts +7 -0
- package/src/index.ts +3 -0
- package/tsconfig.build.json +11 -0
- package/tsconfig.json +16 -0
- package/types/adapter/entry-points/cli/index.d.ts +5 -0
- package/types/adapter/entry-points/cli/index.d.ts.map +1 -0
- package/types/adapter/repositories/GitHubIssueRepository.d.ts +14 -0
- package/types/adapter/repositories/GitHubIssueRepository.d.ts.map +1 -0
- package/types/adapter/repositories/GitHubProjectRepository.d.ts +9 -0
- package/types/adapter/repositories/GitHubProjectRepository.d.ts.map +1 -0
- package/types/adapter/repositories/NodeLocalCommandRunner.d.ts +9 -0
- package/types/adapter/repositories/NodeLocalCommandRunner.d.ts.map +1 -0
- package/types/domain/entities/Issue.d.ts +8 -0
- package/types/domain/entities/Issue.d.ts.map +1 -0
- package/types/domain/entities/Project.d.ts +8 -0
- package/types/domain/entities/Project.d.ts.map +1 -0
- package/types/domain/usecases/NotifyFinishedIssuePreparationUseCase.d.ts +20 -0
- package/types/domain/usecases/NotifyFinishedIssuePreparationUseCase.d.ts.map +1 -0
- package/types/domain/usecases/StartPreparationUseCase.d.ts +17 -0
- package/types/domain/usecases/StartPreparationUseCase.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/IssueRepository.d.ts +8 -0
- package/types/domain/usecases/adapter-interfaces/IssueRepository.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/LocalCommandRunner.d.ts +8 -0
- package/types/domain/usecases/adapter-interfaces/LocalCommandRunner.d.ts.map +1 -0
- package/types/domain/usecases/adapter-interfaces/ProjectRepository.d.ts +5 -0
- package/types/domain/usecases/adapter-interfaces/ProjectRepository.d.ts.map +1 -0
- package/types/index.d.ts +3 -0
- package/types/index.d.ts.map +1 -0
package/.env.example
ADDED
|
File without changes
|
package/.eslintrc.cjs
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
extends: [
|
|
5
|
+
'eslint:recommended',
|
|
6
|
+
'plugin:@typescript-eslint/recommended',
|
|
7
|
+
'plugin:@typescript-eslint/recommended-requiring-type-checking',
|
|
8
|
+
'plugin:import/typescript',
|
|
9
|
+
],
|
|
10
|
+
parser: '@typescript-eslint/parser',
|
|
11
|
+
parserOptions: {
|
|
12
|
+
ecmaVersion: 2020,
|
|
13
|
+
project: ['tsconfig.json'],
|
|
14
|
+
sourceType: 'module',
|
|
15
|
+
},
|
|
16
|
+
plugins: [
|
|
17
|
+
'@typescript-eslint',
|
|
18
|
+
'no-type-assertion',
|
|
19
|
+
'import',
|
|
20
|
+
'unused-imports',
|
|
21
|
+
],
|
|
22
|
+
root: true,
|
|
23
|
+
ignorePatterns: fs.readFileSync('.gitignore', 'utf8').split('\n'),
|
|
24
|
+
rules: {
|
|
25
|
+
'@typescript-eslint/require-await': 'off',
|
|
26
|
+
'@typescript-eslint/no-non-null-assertion': 'error',
|
|
27
|
+
'no-type-assertion/no-type-assertion': 'error',
|
|
28
|
+
'@typescript-eslint/no-unused-vars': [
|
|
29
|
+
'error',
|
|
30
|
+
{
|
|
31
|
+
argsIgnorePattern: '^_',
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
'import/no-restricted-paths': [
|
|
35
|
+
'error',
|
|
36
|
+
{
|
|
37
|
+
zones: [
|
|
38
|
+
{
|
|
39
|
+
target: './src/domain',
|
|
40
|
+
from: './src/adapter',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
target: './src/domain/entities',
|
|
44
|
+
from: './src/domain/usecases',
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
target: './src/adapter/repositories',
|
|
48
|
+
from: './src/adapter/entry-points',
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
'unused-imports/no-unused-imports-ts': 'error',
|
|
54
|
+
},
|
|
55
|
+
overrides: [
|
|
56
|
+
{
|
|
57
|
+
files: ['**/*.test.ts', '**/*.spec.ts'],
|
|
58
|
+
extends: ['plugin:jest/recommended'],
|
|
59
|
+
rules: {
|
|
60
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
61
|
+
'jest/unbound-method': 'error',
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
name: Lint Commit Messages
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
types:
|
|
5
|
+
- opened
|
|
6
|
+
- edited
|
|
7
|
+
- reopened
|
|
8
|
+
- synchronize
|
|
9
|
+
|
|
10
|
+
concurrency:
|
|
11
|
+
group: commitlint-${{ github.ref }}
|
|
12
|
+
cancel-in-progress: true
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
commit-lint:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
issues: read
|
|
19
|
+
pull-requests: write
|
|
20
|
+
contents: read
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout code
|
|
23
|
+
uses: actions/checkout@v6
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
|
|
27
|
+
- name: Use Node.js
|
|
28
|
+
uses: actions/setup-node@v6
|
|
29
|
+
|
|
30
|
+
- name: Check for DONTMERGE
|
|
31
|
+
run: |
|
|
32
|
+
result=$(find . \
|
|
33
|
+
-type f \
|
|
34
|
+
! -path './.github/workflows/commit-lint.yml' \
|
|
35
|
+
! -name '*.snap' \
|
|
36
|
+
-exec grep -Hn 'DONTMERGE' {} \;)
|
|
37
|
+
if [[ ! -z "$result" ]]; then
|
|
38
|
+
echo "$result"
|
|
39
|
+
exit 1
|
|
40
|
+
fi
|
|
41
|
+
- uses: nearform-actions/github-action-check-linked-issues@v1
|
|
42
|
+
id: check-linked-issues
|
|
43
|
+
if: false
|
|
44
|
+
with:
|
|
45
|
+
exclude-branches: 'release/**, dependabot/**, project-common/**'
|
|
46
|
+
loose-matching: true
|
|
47
|
+
- name: Install commitlint
|
|
48
|
+
run: |
|
|
49
|
+
npm install --save-dev @commitlint/{config-conventional,cli}
|
|
50
|
+
- name: Lint commits
|
|
51
|
+
run: |
|
|
52
|
+
npx commitlint --from=origin/main --to=HEAD --config ./.github/workflows/configs/commitlint.config.js
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
extends: ['@commitlint/config-conventional'],
|
|
3
|
+
rules: {
|
|
4
|
+
'type-enum': [
|
|
5
|
+
2,
|
|
6
|
+
'always',
|
|
7
|
+
[
|
|
8
|
+
'build',
|
|
9
|
+
'chore',
|
|
10
|
+
'ci',
|
|
11
|
+
'docs',
|
|
12
|
+
'feat',
|
|
13
|
+
'fix',
|
|
14
|
+
'perf',
|
|
15
|
+
'refactor',
|
|
16
|
+
'revert',
|
|
17
|
+
'style',
|
|
18
|
+
'test',
|
|
19
|
+
'autogen',
|
|
20
|
+
'prep',
|
|
21
|
+
'adapt',
|
|
22
|
+
],
|
|
23
|
+
],
|
|
24
|
+
'header-max-length': [0],
|
|
25
|
+
'body-max-line-length': [0],
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
name: Create PR
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches-ignore:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
create_and_enable_automerge:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- name: Checkout repository
|
|
13
|
+
uses: actions/checkout@v6
|
|
14
|
+
|
|
15
|
+
- name: Set branch name as output
|
|
16
|
+
id: branch_name
|
|
17
|
+
run: echo "::set-output name=branch::${GITHUB_REF#refs/heads/}"
|
|
18
|
+
|
|
19
|
+
- name: Create Pull Request
|
|
20
|
+
id: create_pr
|
|
21
|
+
uses: repo-sync/pull-request@v2
|
|
22
|
+
with:
|
|
23
|
+
github_token: ${{ secrets.GH_TOKEN }}
|
|
24
|
+
destination_branch: 'main'
|
|
25
|
+
source_branch: ''
|
|
26
|
+
pr_title: '${{ steps.branch_name.outputs.branch }}'
|
|
27
|
+
pr_body: |
|
|
28
|
+
:magic_wand: :sparkles:
|
|
29
|
+
|
|
30
|
+
draft: false
|
|
31
|
+
|
|
32
|
+
- name: Assign PR to author
|
|
33
|
+
if: steps.create_pr.outputs.pr_number
|
|
34
|
+
run: |
|
|
35
|
+
curl -s -X POST \
|
|
36
|
+
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
37
|
+
-H "Accept: application/vnd.github.v3+json" \
|
|
38
|
+
-d '{"assignees":["${{ github.actor }}"]}' \
|
|
39
|
+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ steps.create_pr.outputs.pr_number }}/assignees"
|
|
40
|
+
|
|
41
|
+
- name: Get PR Node ID
|
|
42
|
+
if: steps.create_pr.outputs.pr_number
|
|
43
|
+
id: get_pr_id
|
|
44
|
+
run: |
|
|
45
|
+
PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GH_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${{ github.repository }}/pulls/${{ steps.create_pr.outputs.pr_number }}")
|
|
46
|
+
PR_ID=$(echo "$PR_DATA" | jq -r '.node_id')
|
|
47
|
+
echo "::set-output name=node_id::$PR_ID"
|
|
48
|
+
|
|
49
|
+
- name: Enable Auto Merge for PR
|
|
50
|
+
if: steps.create_pr.outputs.pr_number
|
|
51
|
+
run: |
|
|
52
|
+
RESPONSE=$(curl -s -X POST \
|
|
53
|
+
-H "Authorization: bearer ${{ secrets.GH_TOKEN }}" \
|
|
54
|
+
-H "Content-Type: application/json" \
|
|
55
|
+
-d '{
|
|
56
|
+
"query": "mutation($id: ID!) { enablePullRequestAutoMerge(input: { pullRequestId: $id }) { clientMutationId } }",
|
|
57
|
+
"variables": {
|
|
58
|
+
"id": "'"${{ steps.get_pr_id.outputs.node_id }}"'"
|
|
59
|
+
}
|
|
60
|
+
}' \
|
|
61
|
+
"https://api.github.com/graphql")
|
|
62
|
+
echo "$RESPONSE"
|
|
63
|
+
if echo "$RESPONSE" | jq -e '.errors' >/dev/null; then
|
|
64
|
+
echo "Failed to enable auto merge"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Empty format test
|
|
2
|
+
|
|
3
|
+
on: push
|
|
4
|
+
|
|
5
|
+
jobs:
|
|
6
|
+
test:
|
|
7
|
+
runs-on: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- run: echo "test"
|
|
10
|
+
|
|
11
|
+
format:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v6
|
|
17
|
+
with:
|
|
18
|
+
token: ${{ secrets.GH_TOKEN }}
|
|
19
|
+
- uses: actions/setup-node@v6
|
|
20
|
+
with:
|
|
21
|
+
node-version: 25
|
|
22
|
+
- run: git pull
|
|
23
|
+
- run: |
|
|
24
|
+
npx prettier --write "**/*.{md,yaml,yml,js}" --trailing-comma all --print-width 80 --single-quote true
|
|
25
|
+
git --no-pager diff
|
|
26
|
+
- uses: stefanzweifel/git-auto-commit-action@v7
|
|
27
|
+
with:
|
|
28
|
+
commit_message: 'style: re-format / npx prettier --write "**/*.{md,yaml,yml,js}"'
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: 'Format'
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches-ignore:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
format:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v6
|
|
15
|
+
with:
|
|
16
|
+
token: ${{ secrets.GH_TOKEN }}
|
|
17
|
+
- uses: actions/setup-node@v6
|
|
18
|
+
with:
|
|
19
|
+
node-version: 25
|
|
20
|
+
- run: git pull
|
|
21
|
+
- run: npm ci
|
|
22
|
+
- run: npm run fmt && git --no-pager diff
|
|
23
|
+
- uses: stefanzweifel/git-auto-commit-action@v7
|
|
24
|
+
with:
|
|
25
|
+
commit_message: 'style: `npm run fmt`'
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
env:
|
|
9
|
+
RELEASE_APP_ID: 795363
|
|
10
|
+
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
|
|
11
|
+
PJ_GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
publish:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/create-github-app-token@v2
|
|
18
|
+
id: app-token
|
|
19
|
+
with:
|
|
20
|
+
app-id: ${{ env.RELEASE_APP_ID }}
|
|
21
|
+
private-key: ${{ env.RELEASE_APP_PRIVATE_KEY }}
|
|
22
|
+
- uses: actions/checkout@v6
|
|
23
|
+
with:
|
|
24
|
+
token: ${{ steps.app-token.outputs.token }}
|
|
25
|
+
|
|
26
|
+
- uses: actions/setup-node@v6
|
|
27
|
+
with:
|
|
28
|
+
node-version: '25'
|
|
29
|
+
|
|
30
|
+
- run: npm ci
|
|
31
|
+
- run: npm run build
|
|
32
|
+
- run: git config --global user.email "gh-actions"
|
|
33
|
+
- run: git config --global user.name "gh-actions"
|
|
34
|
+
|
|
35
|
+
- run: npx semantic-release
|
|
36
|
+
env:
|
|
37
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
38
|
+
- run: |
|
|
39
|
+
git status
|
|
40
|
+
git add -A
|
|
41
|
+
- run: |
|
|
42
|
+
if git diff --staged --quiet; then
|
|
43
|
+
echo "No changes to commit"
|
|
44
|
+
else
|
|
45
|
+
git commit -m "autogen: release"
|
|
46
|
+
git push --force origin main
|
|
47
|
+
fi
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
test:
|
|
8
|
+
runs-on: ubuntu-latest
|
|
9
|
+
|
|
10
|
+
steps:
|
|
11
|
+
- name: Checkout repository
|
|
12
|
+
uses: actions/checkout@v6
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-node@v6
|
|
17
|
+
with:
|
|
18
|
+
node-version: 25
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: npm ci
|
|
21
|
+
|
|
22
|
+
- name: Build
|
|
23
|
+
run: npm run build
|
|
24
|
+
|
|
25
|
+
- name: Run tests
|
|
26
|
+
run: npm run test
|
|
27
|
+
|
|
28
|
+
- name: Upload test results
|
|
29
|
+
uses: actions/upload-artifact@v6
|
|
30
|
+
with:
|
|
31
|
+
name: jest-junit-report
|
|
32
|
+
path: reports/jest-junit
|
|
33
|
+
|
|
34
|
+
- name: Upload artifacts
|
|
35
|
+
uses: actions/upload-artifact@v6
|
|
36
|
+
with:
|
|
37
|
+
name: reports
|
|
38
|
+
path: reports
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
name: UMINO Project
|
|
2
|
+
on:
|
|
3
|
+
issues:
|
|
4
|
+
types:
|
|
5
|
+
- opened
|
|
6
|
+
- reopened
|
|
7
|
+
- assigned
|
|
8
|
+
- unassigned
|
|
9
|
+
- labeled
|
|
10
|
+
pull_request:
|
|
11
|
+
types:
|
|
12
|
+
- opened
|
|
13
|
+
- reopened
|
|
14
|
+
- review_requested
|
|
15
|
+
- assigned
|
|
16
|
+
- unassigned
|
|
17
|
+
- labeled
|
|
18
|
+
- opened
|
|
19
|
+
- edited
|
|
20
|
+
- reopened
|
|
21
|
+
- synchronize
|
|
22
|
+
issue_comment:
|
|
23
|
+
types:
|
|
24
|
+
- created
|
|
25
|
+
pull_request_target:
|
|
26
|
+
types:
|
|
27
|
+
- opened
|
|
28
|
+
- edited
|
|
29
|
+
- reopened
|
|
30
|
+
- synchronize
|
|
31
|
+
|
|
32
|
+
env:
|
|
33
|
+
unread: Unread
|
|
34
|
+
in_progress: In Progress
|
|
35
|
+
gh_project_token: ${{ secrets.GH_TOKEN }}
|
|
36
|
+
user: HiromiShikata
|
|
37
|
+
project_id: 48
|
|
38
|
+
project_v2_id: PVT_kwHOAGJHa84AFWnr
|
|
39
|
+
field_id: PVTF_lAHOAGJHa84AFWnrzgIk_H0
|
|
40
|
+
team_repo: '7sea.world, blog-tech, media-pinpoint-research, instagram-beauty-aesthetics-review, umino-corporait-operation, instagram-14LBaggageTraveler, hashigoya-project'
|
|
41
|
+
|
|
42
|
+
jobs:
|
|
43
|
+
umino-job:
|
|
44
|
+
if: github.event_name != 'issue_comment' || github.event.comment.user.login != 'umino-bot'
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
steps:
|
|
47
|
+
- name: Move issue to ${{ env.unread }}
|
|
48
|
+
uses: leonsteinhaeuser/project-beta-automations@v2.2.1
|
|
49
|
+
with:
|
|
50
|
+
gh_token: ${{ env.gh_project_token }}
|
|
51
|
+
user: ${{ env.user }}
|
|
52
|
+
project_id: ${{ env.project_id }}
|
|
53
|
+
resource_node_id: ${{ github.event.pull_request.node_id || github.event.issue.node_id }}
|
|
54
|
+
status_value: ${{ env.unread }}
|
|
55
|
+
if: >-
|
|
56
|
+
(github.event_name == 'issues' && github.event.issue.state == 'open') ||
|
|
57
|
+
(github.event_name == 'pull_request' && github.event.pull_request.state == 'open') &&
|
|
58
|
+
(github.event.action == 'opened' || github.event.action == 'reopened' ||
|
|
59
|
+
github.event.action == 'assigned' || github.event.action == 'unassigned')
|
|
60
|
+
- run: |
|
|
61
|
+
OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
|
|
62
|
+
REPO=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
|
63
|
+
ENTITY_TYPE=$(echo ${{ github.event_name }} | grep -q "pull_request" && echo "pullRequest" || echo "issue")
|
|
64
|
+
NUMBER=$(echo ${{ github.event_name }} | grep -q "pull_request" && echo ${{ github.event.pull_request.number }} || echo ${{ github.event.issue.number }})
|
|
65
|
+
|
|
66
|
+
QUERY_DATA='{ "query": "query { repository(owner: \"'$OWNER'\", name: \"'$REPO'\") { '${ENTITY_TYPE}'(number: '$NUMBER') { projectItems(first: 10) { nodes { id } } } } }" }'
|
|
67
|
+
RESPONSE=$(curl -X POST -H "Authorization: bearer ${{ secrets.GH_TOKEN }}" -H "Content-Type: application/json" --data "$QUERY_DATA" https://api.github.com/graphql)
|
|
68
|
+
|
|
69
|
+
if echo $RESPONSE | grep -q "errors"; then
|
|
70
|
+
echo "Error in GraphQL query"
|
|
71
|
+
echo "GraphQL Response: $RESPONSE"
|
|
72
|
+
exit 1
|
|
73
|
+
fi
|
|
74
|
+
|
|
75
|
+
if [ "$ENTITY_TYPE" = "pullRequest" ]; then
|
|
76
|
+
ITEM_ID=$(echo $RESPONSE | jq -r '.data.repository.pullRequest.projectItems.nodes[0].id')
|
|
77
|
+
else
|
|
78
|
+
ITEM_ID=$(echo $RESPONSE | jq -r '.data.repository.issue.projectItems.nodes[0].id')
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
if [ "$ITEM_ID" = "null" ] || [ -z "$ITEM_ID" ]; then
|
|
82
|
+
echo "No valid item ID found, cannot proceed"
|
|
83
|
+
exit 1
|
|
84
|
+
fi
|
|
85
|
+
|
|
86
|
+
CLEAR_FIELD_DATA="{\"query\":\"mutation { clearProjectV2ItemFieldValue(input: {projectId: \\\"${{ env.project_v2_id }}\\\", fieldId: \\\"${{ env.field_id }}\\\", itemId: \\\"$ITEM_ID\\\"}) { clientMutationId }}\"}"
|
|
87
|
+
CLEAR_RESPONSE=$(curl --request POST \
|
|
88
|
+
--url https://api.github.com/graphql \
|
|
89
|
+
--header "Authorization: Bearer ${{ env.gh_project_token }}" \
|
|
90
|
+
--header "Content-Type: application/json" \
|
|
91
|
+
--data "$CLEAR_FIELD_DATA")
|
|
92
|
+
|
|
93
|
+
if echo $CLEAR_RESPONSE | grep -q "errors"; then
|
|
94
|
+
echo "Error in clearing field"
|
|
95
|
+
echo "Clear Field Response: $CLEAR_RESPONSE"
|
|
96
|
+
exit 1
|
|
97
|
+
fi
|
|
98
|
+
if: >-
|
|
99
|
+
((github.event_name == 'issues' && github.event.issue.state == 'open') ||
|
|
100
|
+
(github.event_name == 'pull_request' && github.event.pull_request.state == 'open')) &&
|
|
101
|
+
(github.event.action == 'opened' || github.event.action == 'reopened' ||
|
|
102
|
+
github.event.action == 'assigned' || github.event.action == 'unassigned')
|
|
103
|
+
|
|
104
|
+
- name: Create Issue
|
|
105
|
+
if: ${{ github.event_name == 'issue_comment' && github.event.action == 'created' && contains(github.event.comment.body, '/createissue') }}
|
|
106
|
+
uses: actions/github-script@v8
|
|
107
|
+
with:
|
|
108
|
+
github-token: ${{secrets.GH_TOKEN}}
|
|
109
|
+
script: |
|
|
110
|
+
const commentBody = context.payload.comment.body;
|
|
111
|
+
const createIssueIndex = commentBody.indexOf('/createissue');
|
|
112
|
+
const issueTitle = commentBody.slice(createIssueIndex + 12).split('\n')[0].trim();
|
|
113
|
+
const issueNumber = context.issue.number;
|
|
114
|
+
const commentId = context.payload.comment.id;
|
|
115
|
+
const commentLink = `https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${issueNumber}#issuecomment-${commentId}`;
|
|
116
|
+
const issueBody = `
|
|
117
|
+
${commentBody.slice(createIssueIndex + 12).trim()}
|
|
118
|
+
Created from a comment: ${commentLink}
|
|
119
|
+
`;
|
|
120
|
+
const newIssue = await github.rest.issues.create({
|
|
121
|
+
owner: context.repo.owner,
|
|
122
|
+
repo: context.repo.repo,
|
|
123
|
+
title: issueTitle,
|
|
124
|
+
body: issueBody,
|
|
125
|
+
assignees: ['HiromiShikata']
|
|
126
|
+
});
|
|
127
|
+
- name: Close Issue
|
|
128
|
+
if: ${{ github.event_name == 'issue_comment' && github.event.action == 'created' && (contains(github.event.comment.body, '/close') || contains(github.event.comment.body, '/done')) }}
|
|
129
|
+
uses: actions/github-script@v8
|
|
130
|
+
with:
|
|
131
|
+
github-token: ${{secrets.GH_TOKEN}}
|
|
132
|
+
script: |
|
|
133
|
+
await github.rest.issues.update({
|
|
134
|
+
owner: context.repo.owner,
|
|
135
|
+
repo: context.repo.repo,
|
|
136
|
+
issue_number: context.issue.number,
|
|
137
|
+
state: 'closed'
|
|
138
|
+
});
|
|
139
|
+
- name: Update Date Field
|
|
140
|
+
if: ${{ github.event_name == 'issue_comment' && github.event.action == 'created' && contains(github.event.comment.body, '/movenextactiondateto') }}
|
|
141
|
+
run: |
|
|
142
|
+
DATE_STRING=$(echo "${{ github.event.comment.body }}" | grep -oP '(?<=/movenextactiondateto )\d{8}')
|
|
143
|
+
OWNER=$(echo ${{ github.repository }} | cut -d '/' -f 1)
|
|
144
|
+
REPO=$(echo ${{ github.repository }} | cut -d '/' -f 2)
|
|
145
|
+
ITEM_ID=$(curl -X POST -H "Authorization: bearer ${{ secrets.GH_TOKEN }}" -H "Content-Type: application/json" --data '{ "query": "query { repository(owner: \"'$OWNER'\", name: \"'$REPO'\") { issue(number: '${{ github.event.issue.number }}') { projectItems(first: 10) { nodes { id } } } } }" }' https://api.github.com/graphql | jq -r '.data.repository.issue.projectItems.nodes[0].id')
|
|
146
|
+
UPDATE_FIELD_DATA="{\"query\":\"mutation { updateProjectV2ItemFieldValue(input: {projectId: \\\"${{ env.project_v2_id }}\\\", fieldId: \\\"${{ env.field_id }}\\\", itemId: \\\"$ITEM_ID\\\", value: { date: \\\"$DATE_STRING\\\" }}) { clientMutationId }}\"}"
|
|
147
|
+
curl --request POST \
|
|
148
|
+
-f \
|
|
149
|
+
--url https://api.github.com/graphql \
|
|
150
|
+
--header "Authorization: Bearer ${{ env.gh_project_token }}" \
|
|
151
|
+
--header "Content-Type: application/json" \
|
|
152
|
+
--data "$UPDATE_FIELD_DATA"
|
|
153
|
+
- name: Change Assignee
|
|
154
|
+
if: ${{ github.event_name == 'issue_comment' && github.event.action == 'created' && contains(github.event.comment.body, '/changeassignee ') }}
|
|
155
|
+
uses: actions/github-script@v8
|
|
156
|
+
with:
|
|
157
|
+
github-token: ${{secrets.GH_TOKEN}}
|
|
158
|
+
script: |
|
|
159
|
+
const commentBody = context.payload.comment.body;
|
|
160
|
+
const assigneeIndex = commentBody.indexOf('/changeassignee ') + 16;
|
|
161
|
+
const assigneeName = commentBody.slice(assigneeIndex).split(' ')[0].trim();
|
|
162
|
+
await github.rest.issues.update({
|
|
163
|
+
owner: context.repo.owner,
|
|
164
|
+
repo: context.repo.repo,
|
|
165
|
+
issue_number: context.issue.number,
|
|
166
|
+
assignees: [assigneeName]
|
|
167
|
+
});
|
|
168
|
+
- name: Auto assign issue for non-team repositories
|
|
169
|
+
if: >-
|
|
170
|
+
github.event_name == 'issues' &&
|
|
171
|
+
github.event.action == 'opened' &&
|
|
172
|
+
!contains(env.team_repo, github.event.repository.name)
|
|
173
|
+
uses: pozil/auto-assign-issue@v2.2.0
|
|
174
|
+
with:
|
|
175
|
+
assignees: HiromiShikata
|
|
176
|
+
repo-token: ${{ secrets.GH_TOKEN }}
|
|
177
|
+
|
|
178
|
+
check_pull_requests_to_link_issues:
|
|
179
|
+
runs-on: ubuntu-latest
|
|
180
|
+
name: Check linked issues in pull requests
|
|
181
|
+
if: >-
|
|
182
|
+
(github.event_name == 'pull_request')
|
|
183
|
+
steps:
|
|
184
|
+
- uses: nearform-actions/github-action-check-linked-issues@v1
|
|
185
|
+
id: check-linked-issues
|
|
186
|
+
with:
|
|
187
|
+
exclude-branches: 'release/**, dependabot/**, project-common/**, renovate/**'
|
|
188
|
+
github-token: ${{ secrets.GH_TOKEN }}
|
|
189
|
+
loose-matching: true
|
|
190
|
+
- name: Get the output
|
|
191
|
+
run: echo "How many linked issues? ${{ steps.check-linked-issues.outputs.linked_issues_count }}"
|
package/.prettierignore
ADDED
package/.prettierrc
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# 1.0.0 (2025-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* implement first version ([e696b0a](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/commit/e696b0a9bdd614313d807c8cfad368b62e471b5e))
|
|
7
|
+
|
|
8
|
+
## [1.0.8](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/compare/v1.0.7...v1.0.8) (2025-01-28)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* avoid to trigger initialize job in template repo ([d73e95c](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/commit/d73e95c709f3dabab5712cef45da1abc9a2589ba))
|
|
14
|
+
|
|
15
|
+
## [1.0.7](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/compare/v1.0.6...v1.0.7) (2025-01-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* **deps:** update dependency commander to v13.1.0 ([dde16f1](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/commit/dde16f102132c30b6a801d3cbf266992cdf9f86a))
|
|
21
|
+
|
|
22
|
+
## [1.0.6](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/compare/v1.0.5...v1.0.6) (2025-01-11)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* **deps:** update dependency commander to v13 ([836ba31](https://github.com/HiromiShikata/npm-cli-gh-issue-preparator/commit/836ba310db09c24a2ecbfaca27ee34577e209d48))
|