@@ -18,6 +18,8 @@ scaffold_directory="$INPUT_SCAFFOLDDIRECTORY"
18
18
create_port_entity=" $INPUT_CREATEPORTENTITY "
19
19
branch_name=" port_$port_run_id "
20
20
git_url=" $INPUT_GITHUBURL "
21
+ repo_url=" https://github.com/$org_name /$repository_name "
22
+ add_link_to_port=" $INPUT_ADDLINKTOPORT "
21
23
22
24
get_access_token () {
23
25
curl --silent --show-error --location --request POST ' https://api.getport.io/v1/auth/access_token' --header ' Content-Type: application/json' --data-raw " {
@@ -27,7 +29,7 @@ get_access_token() {
27
29
}
28
30
29
31
send_log () {
30
- message=$1
32
+ local message=$1
31
33
if [[ -n $port_run_id ]]; then
32
34
curl --silent --show-error --location " https://api.getport.io/v1/actions/runs/$port_run_id /logs" \
33
35
--header " Authorization: Bearer $access_token " \
@@ -41,12 +43,16 @@ send_log() {
41
43
}
42
44
43
45
add_link () {
44
- url=$1
46
+ if [[ " $add_link_to_port " != " true" ]]; then
47
+ echo " Skipping adding link to Port"
48
+ return
49
+ fi
50
+ local link_url=$1
45
51
curl --silent --show-error --request PATCH --location " https://api.getport.io/v1/actions/runs/$port_run_id " \
46
52
--header " Authorization: Bearer $access_token " \
47
53
--header " Content-Type: application/json" \
48
54
--data " {
49
- \" link\" : \" $url \"
55
+ \" link\" : \" $link_url \"
50
56
}"
51
57
}
52
58
@@ -113,22 +119,23 @@ apply_cookiecutter_template() {
113
119
}
114
120
115
121
push_to_repository () {
122
+ local default_branch=" master"
116
123
if [ -n " $monorepo_url " ] && [ -n " $scaffold_directory " ]; then
117
124
git config user.name " GitHub Actions Bot"
118
125
git config user.email " github-actions[bot]@users.noreply.github.com"
119
126
git add .
120
127
git commit -m " Scaffolded project in $scaffold_directory "
121
128
git push -u origin " $branch_name "
122
129
123
- send_log " Creating pull request to merge $branch_name into master 🚢"
130
+ send_log " Creating pull request to merge $branch_name into $default_branch 🚢"
124
131
125
132
owner=$( echo " $monorepo_url " | awk -F' /' ' {print $4}' )
126
133
repo=$( echo " $monorepo_url " | awk -F' /' ' {print $5}' )
127
134
128
135
echo " Owner: $owner "
129
136
echo " Repo: $repo "
130
137
131
- PR_PAYLOAD=$( jq -n --arg title " Scaffolded project in $repo " --arg head " $branch_name " --arg base " master " ' {
138
+ PR_PAYLOAD=$( jq -n --arg title " Scaffolded project in $repo " --arg head " $branch_name " --arg base " $default_branch " ' {
132
139
"title": $title,
133
140
"head": $head,
134
141
"base": $base
@@ -152,9 +159,10 @@ push_to_repository() {
152
159
git config user.email " github-actions[bot]@users.noreply.github.com"
153
160
git add .
154
161
git commit -m " Initial commit after scaffolding"
155
- git branch -M master
162
+ git branch -M $default_branch
156
163
git remote add origin " https://oauth2:$github_token @github.com/$org_name /$repository_name .git"
157
- git push -u origin master
164
+ git push -u origin $default_branch
165
+ add_link " $repo_url "
158
166
fi
159
167
}
160
168
@@ -175,7 +183,7 @@ main() {
175
183
if [ -z " $monorepo_url " ] || [ -z " $scaffold_directory " ]; then
176
184
send_log " Creating a new repository: $repository_name 🏃"
177
185
create_repository
178
- send_log " Created a new repository at https://github.com/ $org_name / $repository_name 🚀"
186
+ send_log " New repository created: $repo_url 🚀"
179
187
else
180
188
send_log " Using monorepo scaffolding 🏃"
181
189
clone_monorepo
@@ -185,11 +193,9 @@ main() {
185
193
186
194
send_log " Starting templating with cookiecutter 🍪"
187
195
apply_cookiecutter_template
188
- send_log " Pushing the template into the repository ⬆️ "
196
+ send_log " Pushing the template into the repository. "
189
197
push_to_repository
190
198
191
- url=" https://github.com/$org_name /$repository_name "
192
-
193
199
if [[ " $create_port_entity " == " true" ]]; then
194
200
send_log " Reporting to Port the new entity created 🚢"
195
201
report_to_port
@@ -200,8 +206,9 @@ main() {
200
206
if [ -n " $monorepo_url " ] && [ -n " $scaffold_directory " ]; then
201
207
send_log " Finished! 🏁✅"
202
208
else
203
- send_log " Finished! Visit $url 🏁✅"
209
+ send_log " Finished! Visit $repo_url 🏁✅"
204
210
fi
211
+ echo " repoURL=$repo_url " >> " $GITHUB_OUTPUT "
205
212
}
206
213
207
214
main
0 commit comments