-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.dist.yml
184 lines (168 loc) · 4.65 KB
/
Taskfile.dist.yml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# yaml-language-server: $schema=https://taskfile.dev/schema.json
# https://taskfile.dev/
version: '3'
vars:
# 一連の処理のエラーを捕捉
ON_ERROR: '/tmp/task_on_error_{{base .TASKFILE_DIR}}'
tasks:
default:
cmds:
- task --list --sort alphanumeric -t {{.TASKFILE}}
- gh issue list
silent: true
util:list:
# desc: view all tasks
summary: |
全タスクの出力
aliases:
- ul
- ls
cmd: task --list-all --sort alphanumeric
silent: true
util:summary:
# desc: view summary of all tasks
summary: |
全タスクのサマリー出力
aliases:
- us
- la
cmd: task --list-all --sort alphanumeric -j | jq -cr ".tasks[].name" | xargs -i sh -c 'task --summary {}; echo "\n---\n"'
silent: true
raki:
desc: generate articles
summary: |
__raki_template__.md から記事ファイルを用意する
aliases:
- r
vars:
_A: "__attention__.md"
_T: "articles/__raki_template__.md"
_F:
sh: echo "articles/$(date -I)_raki.md"
preconditions:
- test -f {{._T}}
status:
- test -f {{._F}}
cmds:
- cp {{._T}} {{._F}}
- code {{._F}}
- cat {{._A}}
raki:git:
desc: auto git, use -- COMMIT TITLE
summary: |
記事を書いたら自動で登録
task rg -- コミットタイトル(の一部)
aliases:
- rg
cmds:
- task: _git
vars:
TITLE:
sh: echo "blog(raki):" "$(date -I) {{.CLI_ARGS}}"
BRANCH:
sh: echo "blog/raki/$(date -I)"
TARGET: "articles/ images/"
# 一連の処理のエラーを捕捉
ON_ERROR: /tmp/on_error_raki
terraform:
desc: generate articles
summary: |
__terraform__.md から記事ファイルを用意する
aliases:
- t
vars:
_A: "__attention__.md"
_T: "articles/__terraform__.md"
_F:
sh: echo "articles/$(date -I)_terraform.md"
preconditions:
- test -f {{._T}}
status:
- test -f {{._F}}
cmds:
- cp {{._T}} {{._F}}
- code {{._F}}
- cat {{._A}}
terraform:git:
desc: auto git, use -- COMMIT TITLE
summary: |
記事を書いたら自動で登録
task tg -- コミットタイトル(の一部)
aliases:
- tg
cmds:
- task: _git
vars:
TITLE:
sh: echo "blog(terraform_jp):" "$(date -I) {{.CLI_ARGS}}"
BRANCH:
sh: echo "blog/terraform_jp/$(date -I)"
TARGET: "articles/ images/"
# 一連の処理のエラーを捕捉
ON_ERROR: /tmp/on_error_terraform_jp
_git:
summary: git automation
requires:
vars:
- TITLE
- BRANCH
- TARGET
cmds:
- defer:
task: _git:on_error
- touch {{.ON_ERROR}}
- ls -l {{.ON_ERROR}}
- task: _git:auto
vars:
TITLE: "{{.TITLE}}"
BRANCH: "{{.BRANCH}}"
TARGET: "{{.TARGET}}"
ON_ERROR: "{{.ON_ERROR}}"
- task: _git:gh
vars:
TITLE: "{{.TITLE}}"
BRANCH: "{{.BRANCH}}"
ON_ERROR: "{{.ON_ERROR}}"
# - task: _git:status
- rm {{.ON_ERROR}}
_git:auto:
summary: |
git add, commit, push までを自動化
cmds:
- git fetch --prune --all
- git checkout origin/HEAD
- git add {{.TARGET}}
- git commit -m"{{.TITLE}}"
- git push origin HEAD:refs/heads/{{.BRANCH}} -f
_git:gh:
summary: |
- GitHub CLI を使用して PR を作成し、オートマージを設定する
- push 前までと分離しているのは、エラー時の処理が異なるため
- push 前までのエラーは reset して処理前に戻す
- push 後のエラーは push を再処理する(ON_ERROR のファイルに保存)
- PAT の権限がちゃんとしてないとエラーになることに注意
- オートマージの設定もリポジトリ側に必要
cmds:
- gh pr create -t "{{.TITLE}}" -b "" -l "" -H "{{.BRANCH}}" -B "main"
- gh pr merge "{{.BRANCH}}" --auto -s
_git:status:
# internal: true
silent: true
cmds:
- git plog -5
# see https://github.com/officel/config_git/blob/main/config#L21
- git status --short --branch
_git:on_error:
# internal: true
# silent: true
status:
- test ! -e {{.ON_ERROR}}
# エラーファイルが存在したら処理する
requires:
vars:
- ON_ERROR
cmds:
- defer: rm -f {{.ON_ERROR}}
- ls -l {{.ON_ERROR}}
- cmd: git reset --mixed origin/HEAD
# - task: _git:status