Skip to content

Commit 0f86b0a

Browse files
massongitdev-hato-app[bot]github-actions[bot]
authored
CIで使用しているスクリプトをTypeScript化する (#1814)
* js -> ts * CIで使用しているスクリプトをTypeScript化する * formatが間違ってたので直してあげたよ! (#1815) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * format修正 (#1816) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * format修正 (#1850) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: dev-hato-app[bot] <111467236+dev-hato-app[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent a49838b commit 0f86b0a

33 files changed

Lines changed: 1344 additions & 157 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/** linguist-generated=true
Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
name: update-readme
2+
name: format
33
on:
44
pull_request:
55
types:
@@ -14,7 +14,7 @@ permissions:
1414
contents: write
1515
pull-requests: write
1616
jobs:
17-
update-readme:
17+
format:
1818
runs-on: ubuntu-latest
1919
steps:
2020
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -38,20 +38,26 @@ jobs:
3838
github-token: ${{secrets.GITHUB_TOKEN}}
3939
result-encoding: string
4040
script: |
41-
const script = require('./scripts/update_readme/update_readme/get_inputs_markdown.js')
41+
const {tsImport} = require('tsx/esm/api')
42+
const {script} = await tsImport(
43+
'./scripts/format/format/get_inputs_markdown.ts',
44+
process.env.GITHUB_WORKSPACE + '/'
45+
)
4246
return script()
4347
- env:
4448
INPUTS: ${{steps.get_inputs_markdown.outputs.result}}
4549
if: github.event_name != 'pull_request' || github.event.action != 'closed'
46-
run: bash "${GITHUB_WORKSPACE}/scripts/update_readme/update_readme/update_readme.sh"
50+
run: bash "${GITHUB_WORKSPACE}/scripts/format/format/update_readme.sh"
4751
- run: npx prettier --write .
4852
if: github.event_name != 'pull_request' || github.event.action != 'closed'
53+
- run: tsc
54+
if: github.event_name != 'pull_request' || github.event.action != 'closed'
4955
- uses: ./
5056
with:
5157
github-token: ${{secrets.GITHUB_TOKEN}}
52-
branch-name-prefix: fix-readme
53-
pr-title-prefix: README修正
54-
pr-description-prefix: READMEを修正しました
58+
branch-name-prefix: fix-format
59+
pr-title-prefix: format修正
60+
pr-description-prefix: formatを修正しました
5561
concurrency:
5662
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
5763
cancel-in-progress: true

.github/workflows/super-linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ jobs:
5858
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5959
DEFAULT_BRANCH: main
6060
LINTER_RULES_PATH: .
61-
JAVASCRIPT_DEFAULT_STYLE: prettier
62-
VALIDATE_JAVASCRIPT_STANDARD: false
61+
TYPESCRIPT_DEFAULT_STYLE: prettier
62+
VALIDATE_TYPESCRIPT_STANDARD: false
6363
concurrency:
6464
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
6565
cancel-in-progress: true

.jscpd.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"threshold": 0,
3+
"reporters": ["consoleFull"],
4+
"ignore": ["**/__snapshots__/**", "**/node_modules/**", "**/dist/**"],
5+
"absolute": true
6+
}

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

action.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ runs:
3838
shell: bash
3939
if: github.event_name != 'pull_request' || github.event.action != 'closed'
4040
working-directory: ${{inputs.working-directory}}
41-
run: ${{ github.action_path }}/scripts/action/show_diff.sh
41+
run: ${{ github.action_path }}/src/show_diff.sh
4242
- name: Set env
4343
id: set-env
4444
shell: bash
@@ -60,7 +60,7 @@ runs:
6060
NO_VERIFY: ${{inputs.no-verify}}
6161
if: steps.diff.outputs.result != '' && ((github.event_name == 'pull_request' && github.event.action != 'closed') || github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch')
6262
working-directory: ${{inputs.working-directory}}
63-
run: ${{ github.action_path }}/scripts/action/push.sh
63+
run: ${{ github.action_path }}/src/push.sh
6464
shell: bash
6565
- name: Get a number of PullRequests
6666
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -69,8 +69,8 @@ runs:
6969
with:
7070
github-token: ${{inputs.github-token}}
7171
script: |
72-
const script = require('${{ github.action_path }}/scripts/action/get_number_of_pull_requests.js')
73-
return await script({github, context})
72+
const {script} = require('${{ github.action_path }}/dist/get_number_of_pull_requests.js')
73+
return await script(github, context)
7474
# pushしたブランチで修正PRを作る
7575
- name: Create PullRequest
7676
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -79,8 +79,8 @@ runs:
7979
with:
8080
github-token: ${{inputs.github-token}}
8181
script: |
82-
const script = require('${{ github.action_path }}/scripts/action/create_pull_request.js')
83-
return await script({github, context})
82+
const {script} = require('${{ github.action_path }}/dist/create_pull_request.js')
83+
return await script(github, context)
8484
# 元のPRを出したユーザーを修正PRにアサインする
8585
- name: Assign a user
8686
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -90,8 +90,8 @@ runs:
9090
with:
9191
github-token: ${{inputs.github-token}}
9292
script: |
93-
const script = require('${{ github.action_path }}/scripts/action/assign_a_user.js')
94-
await script({github, context})
93+
const {script} = require('${{ github.action_path }}/dist/assign_a_user.js')
94+
await script(github, context)
9595
# 修正PRのタイトルやDescriptionを更新する
9696
- name: Update PullRequest
9797
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
@@ -100,17 +100,17 @@ runs:
100100
with:
101101
github-token: ${{inputs.github-token}}
102102
script: |
103-
const script = require('${{ github.action_path }}/scripts/action/update_pull_request.js')
104-
return await script({github, context})
103+
const {script} = require('${{ github.action_path }}/dist/update_pull_request.js')
104+
return await script(github, context)
105105
# 既に修正PRがある状態で、手動でformatを修正した場合、修正PRを閉じる
106106
- name: Close PullRequest
107107
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
108108
if: (github.event_name == 'pull_request' && (github.event.action == 'closed' || steps.diff.outputs.result == '')) || ((github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'repository_dispatch') && steps.diff.outputs.result == '')
109109
with:
110110
github-token: ${{inputs.github-token}}
111111
script: |
112-
const script = require('${{ github.action_path }}/scripts/action/close_pull_request.js')
113-
await script({github, context})
112+
const {script} = require('${{ github.action_path }}/dist/close_pull_request.js')
113+
await script(github, context)
114114
# exit-failureがtrueで差分がある場合は異常終了する
115115
- name: Exit
116116
if: (github.event_name != 'pull_request' || github.event.action != 'closed') && steps.diff.outputs.result != '' && inputs.exit-failure == 'true'

dist/assign_a_user.js

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/close_pull_request.js

Lines changed: 30 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/create_pull_request.js

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/generate_title_description.js

Lines changed: 50 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)