refactor: use some variables in PR comments

This commit is contained in:
Alessandro Pezzè 2020-05-13 16:14:42 +02:00
parent bada6cd076
commit 79ebc3e04a

View file

@ -11,6 +11,11 @@ engine_repo='pokeapi'
branch_name='staging'
username='pokeapi-machine-user'
email='pokeapi.co@gmail.com'
staging_environment_url='https://pokeapi-test-b6137.firebaseapp.com/api/v2/'
production_environment_url='https://pokeapi.co/api/v2/'
data_repo_url='https://github.com/PokeAPI/api-data'
engine_circleci_status_url='https://app.circleci.com/pipelines/github/PokeAPI/pokeapi'
deploy_circleci_status_url='https://app.circleci.com/pipelines/github/PokeAPI/deploy'
# Exit the script notifying the user about its success
cleanexit() {
@ -53,7 +58,7 @@ configure_git() {
pr_input_updater_start() {
cat <<EOF
{
"body": "A [PokeAPI/api-data](https://github.com/PokeAPI/api-data) refresh has started. In 45 minutes the staging branch of [PokeAPI/api-data](https://github.com/PokeAPI/api-data/tree/staging) will be pushed with the new generated data. <br><br> The staging branch will be deployed in our [staging environment](https://pokeapi-test-b6137.firebaseapp.com/api/v2/) and you will be able to review the entire API. <br><br> A Pull Request ([master](https://github.com/PokeAPI/api-data/tree/master)<-[staging](https://github.com/PokeAPI/api-data/tree/staging)) will be also created at [PokeAPI/api-data](https://github.com/PokeAPI/api-data/pulls) and assigned to the PokeAPI Core team to be reviewed. If approved and merged new data will soon be available worldwide at [pokeapi.co](https:/pokeapi.co)"
"body": "A [PokeAPI/api-data](${data_repo_url}) refresh has started. In 45 minutes the staging branch of [PokeAPI/api-data](${data_repo_url}/tree/staging) will be pushed with the new generated data. <br><br> The staging branch will be deployed in our [staging environment]($staging_environment_url) and you will be able to review the entire API. <br><br> A Pull Request ([master](${data_repo_url}/tree/master)<-[staging](${data_repo_url}/tree/staging)) will be also created at [PokeAPI/api-data](${data_repo_url}/pulls) and assigned to the PokeAPI Core team to be reviewed. If approved and merged new data will soon be available worldwide at [pokeapi.co]($production_environment_url)"
}
EOF
}
@ -61,7 +66,7 @@ EOF
pr_input_updater_end_success() {
cat <<EOF
{
"body": "The updater script has finished its job and has now opened a Pull Request towards [PokeAPI/api-data](https://github.com/PokeAPI/api-data/pulls) with the updated data. <br><br> You can see the Pull Request deployed at our [staging environment](https://pokeapi-test-b6137.firebaseapp.com/api/v2/) when [CircleCI deploy](https://app.circleci.com/pipelines/github/PokeAPI/deploy) will be finished (_check the started time of the last build_)"
"body": "The updater script has finished its job and has now opened a Pull Request towards [PokeAPI/api-data](${data_repo_url}/pulls) with the updated data. <br><br> You can see the Pull Request deployed at our [staging environment]($staging_environment_url) when [CircleCI deploy]($deploy_circleci_status_url) will be finished (_check the started time of the last build_)"
}
EOF
}
@ -69,7 +74,7 @@ EOF
pr_input_updater_end_failed() {
cat <<EOF
{
"body": "The updater script couldn't finish its job. Please check [CircleCI's builds](https://app.circleci.com/pipelines/github/PokeAPI/pokeapi) and [logs](${CIRCLE_BUILD_URL})."
"body": "The updater script couldn't finish its job. Please check [CircleCI's builds]($engine_circleci_status_url) and [logs](${CIRCLE_BUILD_URL})."
}
EOF
}
@ -120,7 +125,7 @@ pr_input_content() {
cat <<EOF
{
"title": "API data update from \`${org}/${engine_repo}#${1}\`",
"body": "Incoming data generated by [${org}/${engine_repo}](https://github.com/${org}/${engine_repo})'s CircleCI worker since Pull Request [#${1}](https://github.com/${org}/${engine_repo}/pull/${1}) was merged into the \`master\` branch. <br><br> The new data was generated using a copy of [${org}/${engine_repo}](https://github.com/${org}/${engine_repo}/commits/master) repository when the \`HEAD\` was pointing to \`${CIRCLE_SHA1}\`. <br><br> This Pull Request should have been deployed in our [staging environment](https://pokeapi-test-b6137.firebaseapp.com/api/v2/), check [here](https://app.circleci.com/pipelines/github/PokeAPI/deploy) for the lastest build timestamp and status code.",
"body": "Incoming data generated by [${org}/${engine_repo}](https://github.com/${org}/${engine_repo})'s CircleCI worker since Pull Request [#${1}](https://github.com/${org}/${engine_repo}/pull/${1}) was merged into the \`master\` branch. <br><br> The new data was generated using a copy of [${org}/${engine_repo}](https://github.com/${org}/${engine_repo}/commits/master) repository when the \`HEAD\` was pointing to \`${CIRCLE_SHA1}\`. <br><br> This Pull Request should have been deployed in our [staging environment]($staging_environment_url), check [here]($deploy_circleci_status_url) for the lastest build timestamp and status code.",
"head": "$branch_name",
"base": "master",
"assignees": [