Skip to content

Commit c7d5f29

Browse files
committed
ci: add deploy-v3 job for bvp/scraper ^6.0
1 parent f16e927 commit c7d5f29

File tree

2 files changed

+68
-2
lines changed

2 files changed

+68
-2
lines changed

.github/workflows/cron.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,69 @@ jobs:
7878
fi
7979
env:
8080
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
81+
deploy-v3:
82+
needs: deploy-v2
83+
name: Deploy scraper ^6.0
84+
runs-on: ubuntu-24.04
85+
86+
steps:
87+
- name: Setup PHP
88+
uses: shivammathur/setup-php@accd6127cb78bee3e8082180cb391013d204ef9f
89+
with:
90+
php-version: '8.4'
91+
92+
- name: Checkout Code
93+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
94+
with:
95+
fetch-depth: 0
96+
97+
- name: Get Composer cache directory
98+
id: composer-cache
99+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
100+
101+
- name: Cache Composer dependencies
102+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7
103+
with:
104+
path: ${{ steps.composer-cache.outputs.dir }}
105+
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
106+
restore-keys: |
107+
${{ runner.os }}-php-
108+
109+
- name: Install base dependencies (without scraper)
110+
run: |
111+
composer remove bvp/scraper --no-update || true
112+
composer install --no-interaction --no-progress
113+
114+
- name: Require scraper version ^6.0
115+
run: composer require bvp/scraper:^6.0 --no-update
116+
117+
- name: Update lock file for scraper
118+
run: composer update bvp/scraper --with-dependencies
119+
120+
- name: Final install
121+
run: composer install --prefer-dist --no-interaction --no-progress
122+
123+
- name: Scrape Data (v3)
124+
run: php scraper.php v3
125+
126+
- name: Deploy JSON for scraper v3
127+
run: |
128+
git config --global user.name "github-actions[bot]"
129+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
130+
FILES=$(
131+
{
132+
git ls-files -m -- 'docs/v3' | grep '\.json$'
133+
git diff --cached --name-only --diff-filter=AM -- 'docs/v3' | grep '\.json$'
134+
git ls-files --others --exclude-standard -- 'docs/v3' | grep '\.json$'
135+
} | sort -u
136+
)
137+
if [ -n "$FILES" ]; then
138+
git add $FILES
139+
git commit -m "chore: deploy JSON files to docs/v3 [skip ci]" || exit 0
140+
git pull --rebase --autostash
141+
git push origin HEAD
142+
else
143+
echo "No JSON changes in docs/v3 to commit."
144+
fi
145+
env:
146+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

scraper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
// 本日の日付を東京時間で取得
1717
$date = Carbon::today('Asia/Tokyo');
1818

19-
// v2 の場合のみ ProgramScraper を利用して出走表データを取得
20-
if ($version === 'v2') {
19+
// v2 or v3 の場合のみ ProgramScraper を利用して出走表データを取得
20+
if ($version === 'v2' || $version === 'v3') {
2121
$scraperInstance = Scraper::getInstance();
2222
$scraperAdapter = new ScraperAdapter($scraperInstance);
2323
$scraper = new ProgramScraper($scraperAdapter);

0 commit comments

Comments
 (0)