Skip to content
Merged
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
21 changes: 17 additions & 4 deletions .github/workflows/station-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ on:
- "resource/station-dev.csv"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "resource/station-dev.csv"

jobs:
check:
station-csv-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }}
# PR 只需讀取權限,且 fork 的 PR 拿不到 secrets
token: ${{ github.event_name == 'pull_request' && github.token || secrets.PAT_TOKEN }}
fetch-depth: 0
persist-credentials: true
sparse-checkout: |
Expand All @@ -29,12 +28,26 @@ jobs:
scripts/station-check.ts
sparse-checkout-cone-mode: false

# 此 job 為必要檢查,所有 PR 都會觸發;未修改 resource/station-dev.csv 時直接通過
- name: Detect changes
id: changes
run: |
if [ "${{ github.event_name }}" != "pull_request" ] || \
git diff --no-renames --name-only HEAD^1 HEAD | grep -qx "resource/station-dev.csv"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "未修改 resource/station-dev.csv,略過檢查"
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Setup Bun
if: steps.changes.outputs.changed == 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Run station check
if: steps.changes.outputs.changed == 'true'
run: bun run scripts/station-check.ts

- name: Commit and push changes
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/station-json-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,17 @@ on:
- "resource/station-dev.json"
pull_request:
types: [opened, synchronize, reopened]
paths:
- "resource/station-dev.json"

jobs:
check:
station-json-check:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }}
# PR 只需讀取權限,且 fork 的 PR 拿不到 secrets
token: ${{ github.event_name == 'pull_request' && github.token || secrets.PAT_TOKEN }}
fetch-depth: 0
persist-credentials: true
sparse-checkout: |
Expand All @@ -29,12 +28,26 @@ jobs:
scripts/station-json-check.ts
sparse-checkout-cone-mode: false

# 此 job 為必要檢查,所有 PR 都會觸發;未修改 resource/station-dev.json 時直接通過
- name: Detect changes
id: changes
run: |
if [ "${{ github.event_name }}" != "pull_request" ] || \
git diff --no-renames --name-only HEAD^1 HEAD | grep -qx "resource/station-dev.json"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "未修改 resource/station-dev.json,略過檢查"
echo "changed=false" >> "$GITHUB_OUTPUT"
fi

- name: Setup Bun
if: steps.changes.outputs.changed == 'true'
uses: oven-sh/setup-bun@v2
with:
bun-version: latest

- name: Run station JSON check
if: steps.changes.outputs.changed == 'true'
run: bun run scripts/station-json-check.ts

- name: Commit and push changes
Expand Down
Loading