Skip to content

Weekly Batch

Weekly Batch #110

Workflow file for this run

name: Weekly Batch
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
jp-holidays-batch:
runs-on: ubuntu-latest
timeout-minutes: 2
env:
GIT_AUTHOR_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_AUTHOR_NAME: github-actions[bot]
GIT_COMMITTER_EMAIL: github-actions[bot]@users.noreply.github.com
GIT_COMMITTER_NAME: github-actions[bot]
NODE_OPTIONS: --max_old_space_size=7168
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if PR already exists
id: assert-pull-request-not-exists
uses: actions/github-script@v7
with:
script: |
return !(await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: `open`,
head: `${context.repo.owner}:github-actions/batch/jp-holidays-batch`,
base: `main`,
})).data.length
- name: Run batch and create commit
id: update-jp-holidays
if: steps.assert-pull-request-not-exists.outputs.result == 'true'
run: |
node ./dist/index.js
if [ -n "$(git status -zu)" ]; then
git checkout -B github-actions/batch/jp-holidays-batch
git add '*'
git commit -m 'build: update jp-holidays.ts'
git push origin github-actions/batch/jp-holidays-batch
echo '::set-output name=result::true'
fi
- name: Create PR
id: create-pr
if: steps.update-jp-holidays.outputs.result == 'true'
uses: actions/github-script@v7
with:
github-token: ${{secrets.REPO_TOKEN}}
script: |
return (await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `build: update jp-holidays.ts`,
head: `${context.repo.owner}:github-actions/batch/jp-holidays-batch`,
base: `main`,
draft: false,
})).data.number
- name: Enable automerge
if: steps.create-pr.outputs.result
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{secrets.REPO_TOKEN}}
pull-request-number: ${{ steps.create-pr.outputs.result }}
merge-method: squash