-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
198 lines (162 loc) · 4.57 KB
/
Copy pathTaskfile.yml
File metadata and controls
198 lines (162 loc) · 4.57 KB
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
version: "1"
name: fullstack-app
description: "Fullstack: compose overrides, env_file, deploy command, setup command, release command"
variables:
APP_NAME: fullstack-app
IMAGE: ghcr.io/myorg/fullstack-app
TAG: latest
DOMAIN: app.example.com
compose:
file: docker-compose.yml
override_files:
- docker-compose.override.yml
network: proxy
auto_update: true
# Smart defaults: ssh_host → podman/quadlet, env_file → .env.{name}
environments:
local: {}
staging:
ssh_host: staging.example.com
container_runtime: docker
compose_command: docker compose
service_manager: compose
variables:
DOMAIN: staging.example.com
prod:
ssh_host: prod.example.com
variables:
DOMAIN: app.example.com
# ─── Pipeline ─────────────────────────────────────────
pipeline:
python_version: "3.12"
runner_image: ubuntu-latest
docker_in_docker: true
secrets: [GHCR_TOKEN, DEPLOY_SSH_KEY]
cache: [~/.cache/pip, node_modules]
artifacts: [dist/, coverage/]
branches: [main]
stages:
- name: test
tasks: [lint, test]
cache: [~/.cache/pip]
- name: build
tasks: [build, push]
docker_in_docker: true
artifacts: [dist/]
- name: deploy-staging
tasks: [deploy-staging]
env: staging
when: "branch:main"
- name: deploy-prod
tasks: [deploy-prod]
env: prod
when: manual
# ─── Tasks ────────────────────────────────────────────
tasks:
lint:
desc: Run linters
stage: test
cmds:
- ruff check src/
- npm --prefix frontend run lint
ignore_errors: true
test:
desc: Run backend + frontend tests
stage: test
cmds:
- pytest tests/ -v --cov=src/
- npm --prefix frontend test
build:
desc: Build Docker image
stage: build
deps: [test]
cmds:
- docker build -t ${IMAGE}:${TAG} .
push:
desc: Push to GHCR
stage: build
deps: [build]
cmds:
- docker push ${IMAGE}:${TAG}
# ─── Deploy (uses `taskfile deploy` auto-strategy) ──
deploy-local:
desc: "Local: docker compose up"
env: [local]
cmds:
- ${COMPOSE} up -d --build
deploy-staging:
desc: "Staging: remote docker compose"
env: [staging]
cmds:
- "@remote docker compose pull"
- "@remote docker compose up -d"
deploy-prod:
desc: "Prod: Quadlet deploy"
env: [prod]
cmds:
- taskfile quadlet generate
- taskfile quadlet upload --env prod
- "@remote systemctl --user daemon-reload"
- "@remote systemctl --user restart ${APP_NAME}"
# ─── Built-in commands showcase ─────────────────────
init-project:
desc: "Demo: taskfile init --template full"
cmds:
- echo "Run: taskfile init --template full"
- echo "Templates: minimal, web, podman, codereview, full, multiplatform, publish"
validate-config:
desc: "Demo: taskfile validate"
cmds:
- taskfile validate
show-info:
desc: "Demo: taskfile info <task>"
cmds:
- taskfile info build
- taskfile info deploy-prod
generate-ci:
desc: Generate CI for all platforms
cmds:
- taskfile ci generate --all
run-pipeline:
desc: Run full CI pipeline locally
cmds:
- taskfile ci run
preview-ci:
desc: Preview GitHub Actions config
cmds:
- taskfile ci preview --target github
list-tasks:
desc: List all available tasks
cmds:
- taskfile list
dry-run-deploy:
desc: "Preview deploy without executing"
cmds:
- taskfile --env prod --dry-run run deploy-prod
# ─── Ops ────────────────────────────────────────────
logs-staging:
desc: View staging logs
env: [staging]
cmds:
- "@remote docker compose logs -f --tail=100"
logs-prod:
desc: View prod logs
env: [prod]
cmds:
- "@remote journalctl --user -u ${APP_NAME} -f --lines=100"
health:
desc: Check app health
silent: true
cmds:
- curl -sf https://${DOMAIN}/health && echo "OK" || echo "FAIL"
rollback-staging:
desc: Rollback staging
env: [staging]
cmds:
- "@remote docker compose down"
- "@remote docker compose up -d"
clean:
desc: Remove all artifacts
cmds:
- rm -rf dist/ deploy/quadlet/ coverage/
- docker rmi ${IMAGE}:${TAG} 2>/dev/null || true