From cbc5cc96e6ddc1961fad464e24cd7d65ea4b5778 Mon Sep 17 00:00:00 2001 From: EtherealGlow <139999816+EtherealGlow@users.noreply.github.com> Date: Wed, 2 Aug 2023 17:20:49 +0000 Subject: [PATCH 1/9] feat: add workflow to upddate param names --- .github/workflows/update-config.yml | 89 +++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/update-config.yml diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml new file mode 100644 index 000000000..ef72b587e --- /dev/null +++ b/.github/workflows/update-config.yml @@ -0,0 +1,89 @@ +name: Pull Request Action +permissions: write-all +on: + workflow_dispatch: + +env: + GH_TOKEN: ${{ secrets.PAT_TOKEN }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + + - name: Set up Git + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + + - name: Install jq and yq + run: | + sudo apt-get -y install jq + sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq + sudo chmod +x /usr/bin/yq + - name: Update Config Params and Create Pull Requests + run: | + # set up jq script + jq_script=' + .[$new_param] = .[$old_param] | + del(.[$old_param]) + ' + + #urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') + urls="https://github.com/EtherealGlow/ubiquibot-pr-qa" + + for url in $urls + do + repoName=$(basename $url) + ownerName=$(echo $url | awk -F/ '{print $(NF-1)}') + + git clone $url $repoName + cd $repoName + + defaultBranch=$(git branch --show-current) + + # make a branch to update config # + git branch update + git checkout update + + ### update configs ### + # The configurations update code goes here + + declare -A param_mapping=( + ["evm-network-id"]="network-id chain-id" + ["price-multiplier"]="base-multiplier" + #add more configs as needed + ) + + # Iterate over the mapping and perform updates using sed + for new_param in "${!param_mapping[@]}" + do + old_params="${param_mapping[$new_param]}" + for old_param in $old_params + do + jq --arg old_param "$old_param" --arg new_param "$new_param" "$jq_script" ubiquibot-config-default.json > ubiquibot-config-default + mv ubiquibot-config-default ubiquibot-config-default.json + done + done + + git add . + git commit -m "build: use latest ubiquibot config setup" + git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/$ownerName/$repoName.git + git push -f origin update + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}"\ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$ownerName/$repoName/pulls \ + -d '{ + "title": "build: use latest ubiquibot config setup", + "base": "'"$defaultBranch"'", + "head": "update" + }' + + + cd .. + done \ No newline at end of file From c164a6c9dd664115cff2d56e0a0c69a613fec527 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Mon, 14 Aug 2023 09:49:42 +0000 Subject: [PATCH 2/9] feat: add workflow to update params --- .github/workflows/update-config.yml | 57 ++++++++++++++++++----------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index ef72b587e..1d1c2b1d3 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -12,29 +12,29 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v3 - - - name: Set up Git + + - name: Set up git run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" + git config --global user.email "UbiquiBot[dev]@github.com" + git config --global user.name "UbiquiBot[dev]" - name: Install jq and yq run: | sudo apt-get -y install jq sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq sudo chmod +x /usr/bin/yq + + + - name: Commit and Push Changes + run: | + git config --local user.email "UbiquiBot[dev]@github.com" + git config --local user.name "UbiquiBot[dev]" + - name: Update Config Params and Create Pull Requests run: | - # set up jq script - jq_script=' - .[$new_param] = .[$old_param] | - del(.[$old_param]) - ' - - #urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') - urls="https://github.com/EtherealGlow/ubiquibot-pr-qa" + urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') - for url in $urls + for url in $urls do repoName=$(basename $url) ownerName=$(echo $url | awk -F/ '{print $(NF-1)}') @@ -48,30 +48,47 @@ jobs: git branch update git checkout update - ### update configs ### - # The configurations update code goes here + curl -sSL https://raw.githubusercontent.com/ubiquity/ubiquibot/development/ubiquibot-config-default.json > default.json + declare -A param_mapping=( ["evm-network-id"]="network-id chain-id" ["price-multiplier"]="base-multiplier" #add more configs as needed ) - + + ### update configs ### # Iterate over the mapping and perform updates using sed for new_param in "${!param_mapping[@]}" do old_params="${param_mapping[$new_param]}" for old_param in $old_params do - jq --arg old_param "$old_param" --arg new_param "$new_param" "$jq_script" ubiquibot-config-default.json > ubiquibot-config-default - mv ubiquibot-config-default ubiquibot-config-default.json + # only update param if the old ones exist + exist_old_param=$(yq "has(\"$old_param\")" .github/ubiquibot-config.yml) + if $exist_old_param; then + yq ".$new_param = .$old_param | del(.$old_param)" .github/ubiquibot-config.yml > temp.yml + mv temp.yml .github/ubiquibot-config.yml + fi done + # if new param still doesent exist add default from ubiquibot-config-default.json + exist_new_param=$(yq "has(\"$new_param\")" .github/ubiquibot-config.yml) + if ! $exist_new_param; then + echo adding + def_val=$(jq -r ".[\"$new_param\"]" ubiquibot-config-default.json) + yq ".$new_param=$def_val" .github/ubiquibot-config.yml > temp.yml + mv temp.yml .github/ubiquibot-config.yml + fi done - git add . + git config user.email "113181824+UbiquiBot[bot]@users.noreply.github.com" + git config user.name "UbiquiBot[bot]" + + git add .github/ubiquibot-config.yml git commit -m "build: use latest ubiquibot config setup" git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/$ownerName/$repoName.git git push -f origin update + curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ @@ -83,7 +100,5 @@ jobs: "base": "'"$defaultBranch"'", "head": "update" }' - - cd .. done \ No newline at end of file From 45bf48d44ed39792bad59aea9611fa7224cbe1dc Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Mon, 14 Aug 2023 09:55:36 +0000 Subject: [PATCH 3/9] feat: add workflow to update params --- .github/workflows/update-config.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index 1d1c2b1d3..224a7485e 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -13,11 +13,6 @@ jobs: - name: Check out repository uses: actions/checkout@v3 - - name: Set up git - run: | - git config --global user.email "UbiquiBot[dev]@github.com" - git config --global user.name "UbiquiBot[dev]" - - name: Install jq and yq run: | sudo apt-get -y install jq @@ -25,11 +20,6 @@ jobs: sudo chmod +x /usr/bin/yq - - name: Commit and Push Changes - run: | - git config --local user.email "UbiquiBot[dev]@github.com" - git config --local user.name "UbiquiBot[dev]" - - name: Update Config Params and Create Pull Requests run: | urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') From 93dd8c9f4aa9cf60e07c499fe672f52fc91f6e73 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Mon, 14 Aug 2023 15:42:35 +0000 Subject: [PATCH 4/9] feat: add workflow to update param names --- .github/workflows/update-config.yml | 31 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index 224a7485e..8b9fdb8c1 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -10,37 +10,40 @@ jobs: build: runs-on: ubuntu-latest steps: + - name: Check out repository uses: actions/checkout@v3 - + - name: Install jq and yq run: | sudo apt-get -y install jq sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq sudo chmod +x /usr/bin/yq - + - name: Get UbiquiBot Token + uses: tibdex/github-app-token@v1.7.0 + id: get_installation_token + with: + app_id: ${{ secrets.UBIQUITY_BOUNTY_BOT_APP_ID }} + private_key: ${{ secrets.UBIQUITY_BOUNTY_BOT_PRIVATE_KEY }} - name: Update Config Params and Create Pull Requests run: | - urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') - + urls="https://github.com/EtherealGlow/ubiquibot-pr-qa" + for url in $urls do repoName=$(basename $url) ownerName=$(echo $url | awk -F/ '{print $(NF-1)}') - + git clone $url $repoName cd $repoName - defaultBranch=$(git branch --show-current) - + # make a branch to update config # git branch update git checkout update - + curl -sSL https://raw.githubusercontent.com/ubiquity/ubiquibot/development/ubiquibot-config-default.json > default.json - - declare -A param_mapping=( ["evm-network-id"]="network-id chain-id" ["price-multiplier"]="base-multiplier" @@ -70,19 +73,19 @@ jobs: mv temp.yml .github/ubiquibot-config.yml fi done - + git config user.email "113181824+UbiquiBot[bot]@users.noreply.github.com" git config user.name "UbiquiBot[bot]" - + git add .github/ubiquibot-config.yml git commit -m "build: use latest ubiquibot config setup" - git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/$ownerName/$repoName.git + git remote set-url origin https://${{ steps.get_installation_token.outputs.token }}@github.com/$ownerName/$repoName.git git push -f origin update curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.PAT_TOKEN }}"\ + -H "Authorization: Bearer ${{ steps.get_installation_token.outputs.token }}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$ownerName/$repoName/pulls \ -d '{ From d30e6985748c387bfead67eab84b6f483f86fd22 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Mon, 14 Aug 2023 15:46:52 +0000 Subject: [PATCH 5/9] feat: add workflow to update param names --- .github/workflows/update-config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index 8b9fdb8c1..d1c47676a 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -85,7 +85,7 @@ jobs: curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ steps.get_installation_token.outputs.token }}"\ + -H "Authorization: Bearer ${{ secrets.PAT_TOKEN}}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$ownerName/$repoName/pulls \ -d '{ From fb379e52b80944fffa9ea172f4c44de5e316c0e4 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Mon, 14 Aug 2023 15:58:18 +0000 Subject: [PATCH 6/9] feat: add workflow to update param names --- .github/workflows/update-config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index d1c47676a..c86b983e8 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -79,13 +79,13 @@ jobs: git add .github/ubiquibot-config.yml git commit -m "build: use latest ubiquibot config setup" - git remote set-url origin https://${{ steps.get_installation_token.outputs.token }}@github.com/$ownerName/$repoName.git + git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/$ownerName/$repoName.git git push -f origin update curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${{ secrets.PAT_TOKEN}}"\ + -H "Authorization: Bearer ${{ steps.get_installation_token.outputs.token }}"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$ownerName/$repoName/pulls \ -d '{ From 974e8b98646de124c62afcbf556d71d437107245 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Tue, 15 Aug 2023 04:22:28 +0000 Subject: [PATCH 7/9] feat: add workflow to update param names --- .github/workflows/update-config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index c86b983e8..ab1d966b0 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: env: - GH_TOKEN: ${{ secrets.PAT_TOKEN }} + GH_TOKEN: ${{ secrets.UPDATE_CONFIG_PAT }} jobs: build: @@ -79,7 +79,7 @@ jobs: git add .github/ubiquibot-config.yml git commit -m "build: use latest ubiquibot config setup" - git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/$ownerName/$repoName.git + git remote set-url origin https://${{ secrets.UPDATE_CONFIG_PAT }}@github.com/$ownerName/$repoName.git git push -f origin update curl -L \ From 6c4649edc82ee560e000fa8264945426312d6199 Mon Sep 17 00:00:00 2001 From: EtherealGlow Date: Thu, 17 Aug 2023 14:53:21 +0000 Subject: [PATCH 8/9] feat: add workflow to update param names --- .github/workflows/update-config.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index ab1d966b0..e326cc80d 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -19,6 +19,7 @@ jobs: sudo apt-get -y install jq sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq sudo chmod +x /usr/bin/yq + - name: Get UbiquiBot Token uses: tibdex/github-app-token@v1.7.0 id: get_installation_token @@ -28,9 +29,9 @@ jobs: - name: Update Config Params and Create Pull Requests run: | - urls="https://github.com/EtherealGlow/ubiquibot-pr-qa" + urls=$(curl -sSL https://raw.githubusercontent.com/ubiquity/devpool-directory/development/projects.json | jq -r '.urls[]') - for url in $urls + for url in $urls do repoName=$(basename $url) ownerName=$(echo $url | awk -F/ '{print $(NF-1)}') From 470cac8125921edf299c48676e1c2a18e688fc3f Mon Sep 17 00:00:00 2001 From: EtherealGlow <139999816+EtherealGlow@users.noreply.github.com> Date: Thu, 17 Aug 2023 21:17:11 +0530 Subject: [PATCH 9/9] Update update-config.yml --- .github/workflows/update-config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml index e326cc80d..c93d04bfb 100644 --- a/.github/workflows/update-config.yml +++ b/.github/workflows/update-config.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: env: - GH_TOKEN: ${{ secrets.UPDATE_CONFIG_PAT }} + GH_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} jobs: build: @@ -80,7 +80,7 @@ jobs: git add .github/ubiquibot-config.yml git commit -m "build: use latest ubiquibot config setup" - git remote set-url origin https://${{ secrets.UPDATE_CONFIG_PAT }}@github.com/$ownerName/$repoName.git + git remote set-url origin https://${{ secrets.ADD_TO_PROJECT_PAT }}@github.com/$ownerName/$repoName.git git push -f origin update curl -L \