Skip to content

Commit 4c06bea

Browse files
committed
refactor: consolidate scripts into reusable run-script action
- Create .github/actions/run-script/ to run Bun scripts with automatic Bun setup - Move all .github/scripts/*.ts files to .github/actions/run-script/scripts/ - Update all workflows to use the new run-script action instead of direct bun run commands - Remove redundant checkout and setup-bun steps from issue-triggered workflows
1 parent 28dc345 commit 4c06bea

13 files changed

+93
-79
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: 'Run Script'
2+
description: 'Execute a script with Bun and ensure Bun is installed'
3+
inputs:
4+
script:
5+
description: "The script filename to run (located in the action's scripts directory)"
6+
required: true
7+
args:
8+
description: 'Arguments to pass to the script'
9+
required: false
10+
default: ''
11+
12+
outputs:
13+
passed:
14+
description: 'Whether the script passed (mainly for parse-issue.ts)'
15+
value: ${{ steps.run-script.outputs.passed }}
16+
branch:
17+
description: 'Extracted branch name (for parse-issue.ts)'
18+
value: ${{ steps.run-script.outputs.branch }}
19+
commit-sha:
20+
description: 'Extracted commit SHA (for parse-issue.ts)'
21+
value: ${{ steps.run-script.outputs.commit-sha }}
22+
modpack-url:
23+
description: 'Extracted modpack URL (for parse-issue.ts)'
24+
value: ${{ steps.run-script.outputs.modpack-url }}
25+
gt-lang-url:
26+
description: 'Extracted GT lang URL (for parse-issue.ts)'
27+
value: ${{ steps.run-script.outputs.gt-lang-url }}
28+
error:
29+
description: 'Error message if any'
30+
value: ${{ steps.run-script.outputs.error }}
31+
32+
runs:
33+
using: 'composite'
34+
steps:
35+
- name: Check if Bun is installed
36+
id: check-bun
37+
shell: bash
38+
run: |
39+
if command -v bun >/dev/null 2>&1; then
40+
echo "exists=true" >> $GITHUB_OUTPUT
41+
else
42+
echo "exists=false" >> $GITHUB_OUTPUT
43+
fi
44+
45+
- name: Setup Bun
46+
if: steps.check-bun.outputs.exists != 'true'
47+
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
48+
49+
- name: Run script
50+
id: run-script
51+
shell: bash
52+
run: bun run -i ${{ github.action_path }}/scripts/${{ inputs.script }} ${{ inputs.args }}
File renamed without changes.
File renamed without changes.
File renamed without changes.

.github/scripts/setup-nightly-build-datetime-envs.ts renamed to .github/actions/run-script/scripts/setup-nightly-build-datetime-envs.ts

File renamed without changes.

.github/workflows/1-quest-book-to-paratranz.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ jobs:
1717
name: Check And Parse Issue
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v6
22-
with:
23-
sparse-checkout: .github/scripts
24-
25-
- name: Setup Bun
26-
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
27-
2820
- name: Run Script
2921
id: check-and-parse-issue
22+
uses: Kiwi233/Translation-of-GTNH/.github/actions/run-script@master
23+
with:
24+
script: parse-issue.ts
25+
args: quest-book-to-paratranz
3026
env:
3127
GITHUB_ISSUE: ${{ toJSON(github.event.issue) }}
3228
VALID_LABEL: ${{ env.VALID_LABEL }}
3329
VALID_USER: ${{ env.VALID_USER }}
34-
run: |
35-
bun run -i .github/scripts/parse-issue.ts quest-book-to-paratranz
3630
outputs:
3731
passed: ${{ steps.check-and-parse-issue.outputs.passed }}
3832
commit-sha: ${{ steps.check-and-parse-issue.outputs.commit-sha }}

.github/workflows/2-paratranz-to-quest-book.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,16 @@ jobs:
2323
name: Check And Parse Issue
2424
runs-on: ubuntu-latest
2525
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v6
28-
with:
29-
sparse-checkout: .github/scripts
30-
31-
- name: Setup Bun
32-
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
33-
3426
- name: Run Script
3527
id: check-and-parse-issue
28+
uses: Kiwi233/Translation-of-GTNH/.github/actions/run-script@master
29+
with:
30+
script: parse-issue.ts
31+
args: paratranz-to-quest-book
3632
env:
3733
GITHUB_ISSUE: ${{ toJSON(github.event.issue) }}
3834
VALID_LABEL: ${{ env.VALID_LABEL }}
3935
VALID_USER: ${{ env.VALID_USER }}
40-
run: |
41-
bun run -i .github/scripts/parse-issue.ts paratranz-to-quest-book
4236
outputs:
4337
passed: ${{ steps.check-and-parse-issue.outputs.passed }}
4438
branch: ${{ steps.check-and-parse-issue.outputs.branch }}

.github/workflows/3-lang-and-zs-to-paratranz.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,16 @@ jobs:
1919
name: Check And Parse Issue
2020
runs-on: ubuntu-latest
2121
steps:
22-
- name: Checkout
23-
uses: actions/checkout@v6
24-
with:
25-
sparse-checkout: .github/scripts
26-
27-
- name: Setup Bun
28-
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
29-
3022
- name: Run Script
3123
id: check-and-parse-issue
24+
uses: Kiwi233/Translation-of-GTNH/.github/actions/run-script@master
25+
with:
26+
script: parse-issue.ts
27+
args: lang-and-zs-to-paratranz
3228
env:
3329
GITHUB_ISSUE: ${{ toJSON(github.event.issue) }}
3430
VALID_LABEL: ${{ env.VALID_LABEL }}
3531
VALID_USER: ${{ env.VALID_USER }}
36-
run: |
37-
bun run -i .github/scripts/parse-issue.ts lang-and-zs-to-paratranz
3832
outputs:
3933
passed: ${{ steps.check-and-parse-issue.outputs.passed }}
4034
modpack-url: ${{ steps.check-and-parse-issue.outputs.modpack-url }}

.github/workflows/4-paratranz-to-lang-and-zs.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,16 @@ jobs:
2323
name: Check And Parse Issue
2424
runs-on: ubuntu-latest
2525
steps:
26-
- name: Checkout
27-
uses: actions/checkout@v6
28-
with:
29-
sparse-checkout: .github/scripts
30-
31-
- name: Setup Bun
32-
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
33-
3426
- name: Run Script
3527
id: check-and-parse-issue
28+
uses: Kiwi233/Translation-of-GTNH/.github/actions/run-script@master
29+
with:
30+
script: parse-issue.ts
31+
args: paratranz-to-lang-and-zs
3632
env:
3733
GITHUB_ISSUE: ${{ toJSON(github.event.issue) }}
3834
VALID_LABEL: ${{ env.VALID_LABEL }}
3935
VALID_USER: ${{ env.VALID_USER }}
40-
run: |
41-
bun run -i .github/scripts/parse-issue.ts paratranz-to-lang-and-zs
4236
outputs:
4337
passed: ${{ steps.check-and-parse-issue.outputs.passed }}
4438
branch: ${{ steps.check-and-parse-issue.outputs.branch }}

.github/workflows/5-gt-lang-to-paratranz.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,16 @@ jobs:
1717
name: Check And Parse Issue
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v6
22-
with:
23-
sparse-checkout: .github/scripts
24-
25-
- name: Setup Bun
26-
uses: Kiwi233/Translation-of-GTNH/.github/actions/setup-bun@master
27-
2820
- name: Run Script
2921
id: check-and-parse-issue
22+
uses: Kiwi233/Translation-of-GTNH/.github/actions/run-script@master
23+
with:
24+
script: parse-issue.ts
25+
args: gt-lang-to-paratranz
3026
env:
3127
GITHUB_ISSUE: ${{ toJSON(github.event.issue) }}
3228
VALID_LABEL: ${{ env.VALID_LABEL }}
3329
VALID_USER: ${{ env.VALID_USER }}
34-
run: |
35-
bun run -i .github/scripts/parse-issue.ts gt-lang-to-paratranz
3630
outputs:
3731
passed: ${{ steps.check-and-parse-issue.outputs.passed }}
3832
gt-lang-url: ${{ steps.check-and-parse-issue.outputs.gt-lang-url }}

0 commit comments

Comments
 (0)