-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (64 loc) · 2.31 KB
/
batch.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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