-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks-template.py
More file actions
75 lines (65 loc) · 2.31 KB
/
tasks-template.py
File metadata and controls
75 lines (65 loc) · 2.31 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
from invoke import task, UnexpectedExit
import os
import sys
#------------------Brew Tasks------------------#
@task
def brew_manage(c):
"Managing Brew: checking for outdated packages, updating, and upgrading"
try:
c.run("brew outdated")
c.run("brew update")
c.run("brew upgrade")
except UnexpectedExit as e:
if "Cannot install terragrunt because conflicting formulae are installed" in e.result.stderr:
print("Conflicting formulae detected. Unlinking tgenv...")
c.run("brew unlink tgenv")
c.run("brew upgrade")
elif "Cannot install tgenv because conflicting formulae are installed" in e.result.stderr:
print("Conflicting formulae detected. Unlinking terragrunt...")
c.run("brew unlink terragrunt")
c.run("brew upgrade")
elif "Cannot install tfenv because conflicting formulae are installed" in e.result.stderr:
print("Conflicting formulae detected. Unlinking terraform...")
c.run("brew unlink terraform")
c.run("brew upgrade")
elif "Cannot install terraform because conflicting formulae are installed" in e.result.stderr:
print("Conflicting formulae detected. Unlinking tfenv...")
c.run("brew unlink tfenv")
c.run("brew upgrade")
else:
raise e
#------------------Git Tasks------------------#
@task
def git_status(c):
"Check the status of the git repository"
c.run("git status")
@task
def git_pull(c):
"Pull changes from the remote repository"
c.run("git pull origin master")
@task
def git_add(c):
"Add all files to the git repository"
c.run("git add .")
@task
def git_commit(c):
"Commit changes to the git repository"
commit_message = input("Enter commit message: ")
c.run(f'git commit -m "{commit_message}"')
@task
def git_push(c):
"Push changes to the remote repository"
push_message = input("Enter push branch: ")
c.run(f"git push origin {push_message}")
@task
def git_pr(c):
"Create a new pull request"
c.run("gh pr create -d -f -a your-username -r reviewer1,reviewer2,reviewer3")
@task
def git_manage(c):
"Managing Git: checking status, adding all files, committing, and pushing"
git_status(c)
git_add(c)
git_commit(c)
git_push(c)
git_pr(c)