-
Notifications
You must be signed in to change notification settings - Fork 36
/
build-testcase-with-commit-status
executable file
·139 lines (119 loc) · 4.47 KB
/
build-testcase-with-commit-status
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
# Builds a pull request with 2 commit statuses and codeowner approval required
# https://docs.github.com/en/rest/reference/repos#create-a-commit-status
#
# Important: This is not using the GitHub Checks API (GitHub App required)
#
normal=$(tput sgr0)
highlight=$(tput setaf 2)
printf "$highlight"
cat << EOF
________ ____
/_ __/ /_ ___ / __ \____ _ _____ _____
/ / / __ \/ _ \ / /_/ / __ \ | /| / / _ \/ ___/
/ / / / / / __/ / ____/ /_/ / |/ |/ / __/ /
/_/ /_/ /_/\___/ /_/ \____/|__/|__/\___/_/
EOF
printf "${normal}"
#
#
#
printf "${highlight} - Creating repo: ${normal}"
./create-repo-testrepo.sh | jq -r '.name'
./add-team-to-repo.sh
printf "${highlight} - Creating docs/README: ${normal}"
./create-commit-readme.sh | jq -r ".content.html_url"
printf "${highlight} - Creating CODEOWNERS: ${normal}"
./create-commit-codeowners.sh| jq -r ".content.html_url"
sleep 2
printf "${highlight} - Creating new branch: ${normal}"
./create-branch-newbranch.sh | jq -r '.url'
printf "${highlight} - Creating a commit on the new branch: ${normal}"
./create-commit-on-new-branch.sh | jq -r ".content.html_url"
printf "${highlight} - Creating an issue: ${normal}"
./create-repo-issue.sh | jq -r '.html_url'
printf "${highlight} - Creating a pull request: ${normal}"
./create-pull-request.sh | jq -r '.html_url'
# set the branch protection rules for main
printf "${highlight} - Setting branch protection rules on default branch: ${normal}"
./set-branch-protection.sh | jq -r '.url'
printf "${highlight} - Creating a release: ${normal}"
./create-release.sh | jq -r '.url'
printf "${highlight} - Adding a .gitattributes file to new branch: ${normal}"
./create-commit-gitattributes.sh | jq -r ".content.html_url"
printf "${highlight} - Creating commit status for an optional check: ${normal}"
./create-commit-status.sh pending ci/commit-status-optional | jq -r '.url'
printf "${highlight} - Creating commit status for an required check: ${normal}"
./create-commit-status.sh pending ci/commit-status-required | jq -r '.url'
printf "${highlight} - Updating branch protection with required check: ${normal}"
./update-branch-protection-with-required-check.sh | jq -r '.url'
sleep 3
. .gh-api-examples.conf
clear
echo -------------------------------------------
if [ ${pr_approver_token} != "replace_with_a_PAT" ]; then
echo "Do you want to create an approving review by a codeowner using token ${pr_approver_token}:"
x=n
read x
if [ "$x" != "y" ]; then
echo "Skip creating approval review by codeowner"
elif [ "$x" == "y" ]; then
printf "${highlight} - Creating an approving review for a pull request: ${normal}"
./create-approving-review-for-a-pull-request.sh | jq -r '.html_url'
fi
fi
echo -------------------------------------------
# Ask the user if they want to run these two commands to update the check statuses
clear
echo -------------------------------------------
echo
echo "Press y to update the optional commit status to success"
echo "Press any other key to skip this step"
echo
x=n
read x
if [ "$x" != "y" ]; then
echo "Skipping updating the optional commit status"
elif [ "$x" == "y" ]; then
printf "${highlight} - Updating status for optional commit-status-opitonal to success: ${normal}"
./create-commit-status.sh success ci/commit-status-optional | jq -r '.id'
fi
clear
x=n
echo
echo "Press y to update the required commit status to success"
echo "Press any other key to skip this step"
echo
read x
if [ "$x" != "y" ]; then
echo "Skipping updating ci/commit-status-required"
elif [ "$x" == "y" ]; then
printf "${highlight} - Updating status for required check to success: ${normal}"
./create-commit-status.sh success ci/commit-status-required | jq -r '.id'
fi
clear
x=n
echo
echo "Press y to create a check run"
echo "Press any other key to skip this step"
echo
read x
if [ "$x" != "y" ]; then
echo "Skip creating check run"
elif [ "$x" == "y" ]; then
printf "${highlight} - Creating check run with annotation: ${normal}"
check_run_id=$(./tiny-create-check-run-with-annotation.sh | jq -r '.id')
printf "${highlight} - Created check run id: ${check_run_id} ${normal}"
fi
clear
x=n
echo
echo "Press y to update check run id ${check_run_id}"
echo "Press any other key to skip this step"
echo
read x
if [ "$x" != "y" ]; then
echo "Skip updating check run"
elif [ "$x" == "y" ]; then
printf "${highlight} - Updating check run id: $check_run_id ${normal}"
./tiny-update-a-check-run.sh ${check_run_id}
fi