Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIで使用しているスクリプトをTypeScript化する #1814

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/** linguist-generated=true
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: update-readme
name: format
on:
pull_request:
types:
Expand All @@ -14,7 +14,7 @@ permissions:
contents: write
pull-requests: write
jobs:
update-readme:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand All @@ -38,20 +38,26 @@ jobs:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
const script = require('./scripts/update_readme/update_readme/get_inputs_markdown.js')
const {tsImport} = require('tsx/esm/api')
const {script} = await tsImport(
'./scripts/format/format/get_inputs_markdown.ts',
process.env.GITHUB_WORKSPACE + '/'
)
return script()
- env:
INPUTS: ${{steps.get_inputs_markdown.outputs.result}}
if: github.event_name != 'pull_request' || github.event.action != 'closed'
run: bash "${GITHUB_WORKSPACE}/scripts/update_readme/update_readme/update_readme.sh"
run: bash "${GITHUB_WORKSPACE}/scripts/format/format/update_readme.sh"
- run: npx prettier --write .
if: github.event_name != 'pull_request' || github.event.action != 'closed'
- run: tsc
if: github.event_name != 'pull_request' || github.event.action != 'closed'
- uses: ./
with:
github-token: ${{secrets.GITHUB_TOKEN}}
branch-name-prefix: fix-readme
pr-title-prefix: README修正
pr-description-prefix: READMEを修正しました
branch-name-prefix: fix-format
pr-title-prefix: format修正
pr-description-prefix: formatを修正しました
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
4 changes: 2 additions & 2 deletions .github/workflows/super-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DEFAULT_BRANCH: main
LINTER_RULES_PATH: .
JAVASCRIPT_DEFAULT_STYLE: prettier
VALIDATE_JAVASCRIPT_STANDARD: false
TYPESCRIPT_DEFAULT_STYLE: prettier
VALIDATE_TYPESCRIPT_STANDARD: false
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.ref }}
cancel-in-progress: true
6 changes: 6 additions & 0 deletions .jscpd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"threshold": 0,
"reporters": ["consoleFull"],
"ignore": ["**/__snapshots__/**", "**/node_modules/**", "**/dist/**"],
"absolute": true
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/
24 changes: 12 additions & 12 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ runs:
shell: bash
if: github.event_name != 'pull_request' || github.event.action != 'closed'
working-directory: ${{inputs.working-directory}}
run: ${{ github.action_path }}/scripts/action/show_diff.sh
run: ${{ github.action_path }}/src/show_diff.sh
- name: Set env
id: set-env
shell: bash
Expand All @@ -60,7 +60,7 @@ runs:
NO_VERIFY: ${{inputs.no-verify}}
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')
working-directory: ${{inputs.working-directory}}
run: ${{ github.action_path }}/scripts/action/push.sh
run: ${{ github.action_path }}/src/push.sh
shell: bash
- name: Get a number of PullRequests
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -69,8 +69,8 @@ runs:
with:
github-token: ${{inputs.github-token}}
script: |
const script = require('${{ github.action_path }}/scripts/action/get_number_of_pull_requests.js')
return await script({github, context})
const {script} = require('${{ github.action_path }}/dist/get_number_of_pull_requests.js')
return await script(github, context)
# pushしたブランチで修正PRを作る
- name: Create PullRequest
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -79,8 +79,8 @@ runs:
with:
github-token: ${{inputs.github-token}}
script: |
const script = require('${{ github.action_path }}/scripts/action/create_pull_request.js')
return await script({github, context})
const {script} = require('${{ github.action_path }}/dist/create_pull_request.js')
return await script(github, context)
# 元のPRを出したユーザーを修正PRにアサインする
- name: Assign a user
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -90,8 +90,8 @@ runs:
with:
github-token: ${{inputs.github-token}}
script: |
const script = require('${{ github.action_path }}/scripts/action/assign_a_user.js')
await script({github, context})
const {script} = require('${{ github.action_path }}/dist/assign_a_user.js')
await script(github, context)
# 修正PRのタイトルやDescriptionを更新する
- name: Update PullRequest
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
Expand All @@ -100,17 +100,17 @@ runs:
with:
github-token: ${{inputs.github-token}}
script: |
const script = require('${{ github.action_path }}/scripts/action/update_pull_request.js')
return await script({github, context})
const {script} = require('${{ github.action_path }}/dist/update_pull_request.js')
return await script(github, context)
# 既に修正PRがある状態で、手動でformatを修正した場合、修正PRを閉じる
- name: Close PullRequest
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
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 == '')
with:
github-token: ${{inputs.github-token}}
script: |
const script = require('${{ github.action_path }}/scripts/action/close_pull_request.js')
await script({github, context})
const {script} = require('${{ github.action_path }}/dist/close_pull_request.js')
await script(github, context)
# exit-failureがtrueで差分がある場合は異常終了する
- name: Exit
if: (github.event_name != 'pull_request' || github.event.action != 'closed') && steps.diff.outputs.result != '' && inputs.exit-failure == 'true'
Expand Down
14 changes: 14 additions & 0 deletions dist/assign_a_user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions dist/close_pull_request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions dist/create_pull_request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions dist/generate_title_description.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions dist/get_number_of_pull_requests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions dist/get_pull_requests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions dist/update_pull_request.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading