Skip to content

Commit 3765956

Browse files
committed
🔧 chore: add Heroku management tasks and use env variables
- Add 11 new Heroku tasks: logs, restart, shell, bash, migrate, config, ps, releases, rollback, maintenance:on/off - Add HEROKU_APP and PGDATABASE environment variables - Use $PGDATABASE in database:drop, database:pull, database:push
1 parent c0c7a5f commit 3765956

1 file changed

Lines changed: 60 additions & 3 deletions

File tree

Taskfile.yaml

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,29 @@ version: '3'
55

66
env:
77
DOCKER_IMAGE: python.ie/website-dev
8+
PGDATABASE: pythonie
89
PGPASSWORD: pythonie
910
PGUSER: postgres
1011
PGHOST: 127.0.0.1
12+
HEROKU_APP: pythonie
1113

1214
dotenv: ['production.env']
1315

1416
tasks:
1517
database:drop:
1618
desc: Drop the local PostgreSQL database
1719
cmds:
18-
- docker compose exec -u postgres postgres dropdb --if-exists pythonie
20+
- docker compose exec -u postgres postgres dropdb --if-exists $PGDATABASE
1921

2022
database:pull:
2123
desc: Pull the database from Heroku and store it into a localhost PostgreSQL
2224
cmds:
23-
- heroku pg:pull $HEROKU_POSTGRESQL_IDENTIFIER pythonie
25+
- heroku pg:pull $HEROKU_POSTGRESQL_IDENTIFIER $PGDATABASE
2426

2527
database:push:
2628
desc: Push the database from local PostgreSQL to Heroku
2729
cmds:
28-
- heroku pg:push pythonie $HEROKU_POSTGRESQL_IDENTIFIER
30+
- heroku pg:push $PGDATABASE $HEROKU_POSTGRESQL_IDENTIFIER
2931

3032
database:reset:
3133
desc: Reset the database with a fresh copy of the official database
@@ -43,6 +45,61 @@ tasks:
4345
cmds:
4446
- heroku pg:backups:capture
4547

48+
heroku:logs:
49+
desc: View application logs in real-time
50+
cmds:
51+
- heroku logs --tail
52+
53+
heroku:restart:
54+
desc: Restart the Heroku application
55+
cmds:
56+
- heroku restart
57+
58+
heroku:shell:
59+
desc: Run Django shell on Heroku
60+
cmds:
61+
- heroku run python pythonie/manage.py shell --settings=pythonie.settings.production
62+
63+
heroku:bash:
64+
desc: Run bash shell on Heroku
65+
cmds:
66+
- heroku run bash
67+
68+
heroku:migrate:
69+
desc: Run database migrations on Heroku
70+
cmds:
71+
- heroku run python pythonie/manage.py migrate --settings=pythonie.settings.production
72+
73+
heroku:config:
74+
desc: Show Heroku environment variables
75+
cmds:
76+
- heroku config
77+
78+
heroku:ps:
79+
desc: Show dyno status
80+
cmds:
81+
- heroku ps
82+
83+
heroku:releases:
84+
desc: Show deployment history
85+
cmds:
86+
- heroku releases
87+
88+
heroku:rollback:
89+
desc: Rollback to previous release
90+
cmds:
91+
- heroku rollback
92+
93+
heroku:maintenance:on:
94+
desc: Enable maintenance mode
95+
cmds:
96+
- heroku maintenance:on
97+
98+
heroku:maintenance:off:
99+
desc: Disable maintenance mode
100+
cmds:
101+
- heroku maintenance:off
102+
46103
run:postgres:
47104
desc: Only run the PostgreSQL server, for example, if you want to restore the database from Heroku
48105
cmds:

0 commit comments

Comments
 (0)