Skip to content

Commit

Permalink
build (毎年)と touch (毎月) で GitHub Actions を分ける
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuoshi committed Sep 9, 2024
1 parent 0eabd54 commit f29e0ed
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 19 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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') }}
Expand All @@ -27,18 +27,18 @@ 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
then
git config user.email "[email protected]"
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
42 changes: 42 additions & 0 deletions .github/workflows/touch.yml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
git config user.name "from GitHub Actions"
git add --all
git commit -m "touch"
git push
fi
8 changes: 0 additions & 8 deletions app/holidaysJP.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public function generate()
foreach ($yearly as $year => $a) {
$this->generate_api_file($a, $year);
}

$this->updateCheckedFile();
}

/**
Expand Down Expand Up @@ -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'));
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit f29e0ed

Please sign in to comment.