diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index faa62e5..7a257e3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,22 +1,22 @@ -name: PHP Composer +name: Build on: - push: - branches: [ master, v1.1, build-test ] schedule: - - cron: '5 15 1,31 * *' + - cron: '0 15 31 12 *' + workflow_dispatch: + push: + branches: [ build-test ] jobs: build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Cache Composer packages id: composer-cache - uses: actions/cache@v2 + uses: actions/cache@v4 with: path: vendor key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} @@ -27,11 +27,11 @@ jobs: run: composer install --prefer-dist --no-progress - name: build api files + env: + TZ: 'Asia/Tokyo' run: composer build - name: commit and push - env: - TZ: 'Asia/Tokyo' run: | git add -N . if ! git diff --exit-code --quiet @@ -39,6 +39,6 @@ jobs: git config user.email "matsuoshi@gmail.com" git config user.name "from GitHub Actions" git add --all - git commit -m "$(date +'%Y-%m-%d %H:%M:%S')" + git commit -m "build" git push fi diff --git a/.github/workflows/touch.yml b/.github/workflows/touch.yml new file mode 100644 index 0000000..9f80891 --- /dev/null +++ b/.github/workflows/touch.yml @@ -0,0 +1,42 @@ +name: touch + +on: + schedule: + - cron: '0 3 1 * *' + workflow_dispatch: + +jobs: + touch: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v4 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: touch + env: + TZ: 'Asia/Tokyo' + run: composer touch + + - name: commit and push + run: | + git add -N . + if ! git diff --exit-code --quiet + then + git config user.email "matsuoshi@gmail.com" + git config user.name "from GitHub Actions" + git add --all + git commit -m "touch" + git push + fi diff --git a/app/holidaysJP.php b/app/holidaysJP.php index b353864..8b6268e 100644 --- a/app/holidaysJP.php +++ b/app/holidaysJP.php @@ -45,8 +45,6 @@ public function generate() foreach ($yearly as $year => $a) { $this->generate_api_file($a, $year); } - - $this->updateCheckedFile(); } /** @@ -212,10 +210,4 @@ protected function output_csv_file($filename, $data) } fclose($fp); } - - protected function updateCheckedFile() - { - $checkedFile = self::DIST . '/checked_at.txt'; - file_put_contents($checkedFile, date('Y-m-d H:i:s')); - } } diff --git a/composer.json b/composer.json index c3fb47a..48b5fa1 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,8 @@ "phpunit/phpunit": "^9.5" }, "scripts": { - "build": "php main.php", + "build": "php main.php && composer touch", + "touch": "date '+%F %T' > docs/v1/checked_at.txt", "test": "phpunit" } }