generate-and-commit-files-by-crontab #679
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: generate-and-commit-files-by-crontab | |
on: | |
schedule: | |
- cron: '0 0 * * */2' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [12.x] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v1 | |
- name: Change language | |
run: | | |
sudo apt-get install language-pack-ja | |
sudo update-locale LANG=ja_JP.UTF-8 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install deps | |
run: | | |
npm ci | |
- name: Build | |
run: | | |
npm run build | |
# - name: Update last updated | |
# run: | | |
# sed -i "s/\(last auto-updated time: \).*$/\1$(stat --format="%x" output/result.jpg)/g" ./README.md | |
- name: Commit to repository | |
env: | |
GITHUB_TOKEN: ${{ secrets.github_token }} | |
COMMIT_MSG: | | |
update result.jpg and readme | |
run: | | |
git config user.email "no-reply@hiroppy.me" | |
git config user.name "hiroppy-bot" | |
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git | |
git checkout master | |
git add . | |
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin master) |