From 4d098942d3eb056d08f96ef3ba7a4445f0fea6fa Mon Sep 17 00:00:00 2001 From: Naramsim Date: Wed, 13 Dec 2023 11:22:36 +0100 Subject: [PATCH 1/2] cicd: get pr number earlier --- Resources/scripts/updater.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Resources/scripts/updater.sh b/Resources/scripts/updater.sh index b0b2517d3..4f464f445 100644 --- a/Resources/scripts/updater.sh +++ b/Resources/scripts/updater.sh @@ -168,6 +168,7 @@ run_updater() { cd "$data_repo/updater" || cleanexit 'fail' "Failed to cd" # Wait to be sure PokeAPI/pokeapi's master branch has been updated on Github with the lastest merged PR content sleep 10 + engine_repo_pr_number=$(get_invokator_pr_number) # Build the updater image docker build -t pokeapi-updater . @@ -177,7 +178,7 @@ run_updater() { # Run the updater docker network create pokeapi - docker run --privileged --network pokeapi --network-alias docker -e REPO_POKEAPI_CHECKOUT_OBJECT="$CIRCLE_SHA1" -e COMMIT_EMAIL="$email" -e COMMIT_NAME="$username" -e BRANCH_NAME="$branch_name" -e REPO_POKEAPI="https://github.com/$org/$engine_repo.git" -e REPO_DATA="https://$MACHINE_USER_GITHUB_API_TOKEN@github.com/$org/$data_repo.git" -e COMMIT_MESSAGE="[Updater Bot] Regenerate data from https://github.com/$org/$engine_repo/pull/$(get_invokator_pr_number)" -e COMMIT_AND_PUSH='true' -e RUN_AS='root' pokeapi-updater + docker run --privileged --network pokeapi --network-alias docker -e REPO_POKEAPI_CHECKOUT_OBJECT="$CIRCLE_SHA1" -e COMMIT_EMAIL="$email" -e COMMIT_NAME="$username" -e BRANCH_NAME="$branch_name" -e REPO_POKEAPI="https://github.com/$org/$engine_repo.git" -e REPO_DATA="https://$MACHINE_USER_GITHUB_API_TOKEN@github.com/$org/$data_repo.git" -e COMMIT_MESSAGE="[Updater Bot] Regenerate data from https://github.com/$org/$engine_repo/pull/$engine_repo_pr_number" -e COMMIT_AND_PUSH='true' -e RUN_AS='root' pokeapi-updater return_code=$? if [ "$return_code" -eq 2 ]; then cleanexit 'no-new-data' "Generated data is the same as old data, skipping deploy" From e8a2b6f21e8e55f9ed2c8f0b04b9676bb376b5b6 Mon Sep 17 00:00:00 2001 From: Naramsim Date: Fri, 15 Dec 2023 08:05:13 +0100 Subject: [PATCH 2/2] chore: get PR number in the right folder/grammar --- Resources/scripts/updater.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Resources/scripts/updater.sh b/Resources/scripts/updater.sh index 4f464f445..ad4bdd0e8 100644 --- a/Resources/scripts/updater.sh +++ b/Resources/scripts/updater.sh @@ -115,7 +115,7 @@ configure_git() { pr_input_updater_start() { cat <
The staging branch will be deployed in our [staging environment]($staging_environment_url) and you will be able to review the entire API.

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)." + "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.

The staging branch will be deployed in our [staging environment]($staging_environment_url) and the entire API will be ready to review.

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 } @@ -123,7 +123,7 @@ EOF pr_input_updater_end_success() { cat <
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_)." + "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.

The Pull Request can be seen deployed in our [staging environment]($staging_environment_url) when [CircleCI deploy]($deploy_circleci_status_url) will be finished (_check the start time of the last build_)." } EOF } @@ -165,10 +165,10 @@ notify_engine_pr() { # Run the updater script (https://github.com/PokeAPI/api-data/blob/master/updater/cmd.bash) which will generate the new pokeapi data and push it to the api-data repository under a new branch run_updater() { + engine_repo_pr_number=$(get_invokator_pr_number) cd "$data_repo/updater" || cleanexit 'fail' "Failed to cd" # Wait to be sure PokeAPI/pokeapi's master branch has been updated on Github with the lastest merged PR content sleep 10 - engine_repo_pr_number=$(get_invokator_pr_number) # Build the updater image docker build -t pokeapi-updater .