mirror of
https://github.com/PokeAPI/pokeapi
synced 2024-11-10 06:04:18 +00:00
play: open PR towards api-data
This commit is contained in:
parent
96478a2fcd
commit
0951d79dc7
2 changed files with 78 additions and 13 deletions
|
@ -19,19 +19,8 @@ jobs:
|
|||
fingerprints:
|
||||
- "d3:5f:9d:68:ea:12:9a:42:d3:d3:e1:db:b0:6a:fc:d2"
|
||||
- run:
|
||||
name: TEST - Create test branch on api-data # TODO: move to the deploy phase TODO: rename
|
||||
command: |
|
||||
mkdir -p ./testpr
|
||||
cd testpr
|
||||
git clone https://github.com/PokeAPI/api-data.git api-data
|
||||
cd api-data
|
||||
git checkout -b testbranch
|
||||
touch .gitkeeptestpr
|
||||
git config --global user.name "pokeapi-machine-user"
|
||||
git config --global user.email pokeapi.co@gmail.com
|
||||
git add .
|
||||
git commit -m "play: add test file"
|
||||
git push -uf origin testbranch
|
||||
name: TEST - Create test branch on api-data and relative PR # TODO: move to the deploy phase TODO: rename
|
||||
command: bash Resources/scripts/updater.sh
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
|
|
76
Resources/scripts/updater.sh
Normal file
76
Resources/scripts/updater.sh
Normal file
|
@ -0,0 +1,76 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -o pipefail
|
||||
|
||||
org='PokeAPI'
|
||||
data_repo='api-data'
|
||||
branch_name='testbranch'
|
||||
|
||||
prepare() {
|
||||
mkdir -p ./testpr
|
||||
cd testpr || exit
|
||||
}
|
||||
|
||||
clone() {
|
||||
git clone "https://github.com/$org/$data_repo.git" "$data_repo"
|
||||
cd "$data_repo" || exit
|
||||
}
|
||||
|
||||
configure_git() {
|
||||
git config --global user.name "pokeapi-machine-user"
|
||||
git config --global user.email pokeapi.co@gmail.com
|
||||
}
|
||||
|
||||
push() {
|
||||
git checkout -b "$branch_name"
|
||||
touch .gitkeeptestpr
|
||||
git add .
|
||||
git commit -m "play: add test file"
|
||||
git push -uf origin "$branch_name"
|
||||
}
|
||||
|
||||
pr_content() {
|
||||
cat <<EOF
|
||||
{
|
||||
"title": "API data update",
|
||||
"body": 'Incoming data generated by https://github.com/PokeAPI/pokeapi CircleCI worker',
|
||||
"head": "$branch_name",
|
||||
"base": "master",
|
||||
"assignees": [
|
||||
"Naramsim"
|
||||
],
|
||||
"labels": [
|
||||
"api-data-update"
|
||||
]
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
reviewers() {
|
||||
cat <<EOF
|
||||
{
|
||||
"reviewers": [
|
||||
"Naramsim"
|
||||
]
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
create_pr() {
|
||||
pr_number=$(curl -H "Authorization: token $GITHUB_API_TOKEN" -X POST --data "$(pr_content)" "https://api.github.com/repos/$org/$data_repo/pulls" | jq '.number')
|
||||
echo pr_number
|
||||
}
|
||||
|
||||
assign_pr() {
|
||||
pr_number=$1
|
||||
curl -H "Authorization: token $GITHUB_API_TOKEN" -X POST --data "$(reviewers)" "https://api.github.com/repos/$org/$data_repo/pulls/$pr_number/requested_reviewers"
|
||||
}
|
||||
|
||||
prepare
|
||||
clone
|
||||
configure_git
|
||||
push
|
||||
sleep 5
|
||||
pr_number=create_pr
|
||||
sleep 5
|
||||
assign_pr "$pr_number"
|
Loading…
Reference in a new issue