From 3ee39e0239062acef83db760751989e7be8ff532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AC=E3=82=AF=E3=82=B5=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=2Eeth?= Date: Thu, 14 Dec 2023 15:38:52 +0900 Subject: [PATCH] chore: check necessary environment variables --- .env.example | 2 +- .github/workflows/e2e-test.yml | 3 +- .github/workflows/qa-automation.yml | 35 ----------- .github/workflows/update-config.yml | 98 ----------------------------- README.md | 8 +-- src/types/configuration-types.ts | 4 +- 6 files changed, 8 insertions(+), 142 deletions(-) delete mode 100644 .github/workflows/qa-automation.yml delete mode 100644 .github/workflows/update-config.yml diff --git a/.env.example b/.env.example index b3eff4fe1..57723efc4 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ APP_ID= -PRIVATE_KEY= +APP_PRIVATE_KEY= # Go to https://smee.io/new set this to the URL that you are redirected to. WEBHOOK_PROXY_URL= diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index b08f45cff..f9b4cd32a 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -37,10 +37,9 @@ jobs: # MEASURE_SIMILARITY_AI_TEMPERATURE: # OPENAI_API_HOST: # OPENAI_API_KEY: - PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }} # SIMILARITY_THRESHOLD: SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }} - # SUPABASE_PROJECT_ID: SUPABASE_URL: ${{ secrets.SUPABASE_URL }} TEST_ADMIN_PAT: ${{ secrets.TEST_ADMIN_PAT }} TEST_ORGANIZATION_NAME: ${{ secrets.TEST_ORGANIZATION_NAME }} diff --git a/.github/workflows/qa-automation.yml b/.github/workflows/qa-automation.yml deleted file mode 100644 index 2b8aafa53..000000000 --- a/.github/workflows/qa-automation.yml +++ /dev/null @@ -1,35 +0,0 @@ -name: Automate QA - -on: - pull_request_target: - types: - - review_requested - branches: [development, main] - -jobs: - add-to-project: - env: - ADD_TO_PROJECT_PAT: ${{ secrets.ADD_TO_PROJECT_PAT }} - name: Add issue to project - runs-on: ubuntu-latest - permissions: - contents: read - - steps: - - name: Add PR to QA project - if: contains(github.event.pull_request.requested_reviewers.*.login, 'Draeieg') - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/ubiquity/projects/23 - github-token: ${{ env.ADD_TO_PROJECT_PAT }} - - - name: Create QA Issue - if: contains(github.event.pull_request.requested_reviewers.*.login, 'Draeieg') - uses: dacbd/create-issue-action@v1 - with: - token: ${{ env.ADD_TO_PROJECT_PAT }} - owner: ubiquibot - repo: staging - title: QA for ${{ github.event.pull_request.title }} - body: | - Testing pr ${{ github.event.pull_request.number }} diff --git a/.github/workflows/update-config.yml b/.github/workflows/update-config.yml deleted file mode 100644 index c93d04bfb..000000000 --- a/.github/workflows/update-config.yml +++ /dev/null @@ -1,98 +0,0 @@ -name: Pull Request Action -permissions: write-all -on: - workflow_dispatch: - -env: - GH_TOKEN: ${{ secrets.ADD_TO_PROJECT_PAT }} - -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[]') - - 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" - #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 - # 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 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.ADD_TO_PROJECT_PAT }}@github.com/$ownerName/$repoName.git - git push -f origin update - - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -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 '{ - "title": "build: use latest ubiquibot config setup", - "base": "'"$defaultBranch"'", - "head": "update" - }' - cd .. - done \ No newline at end of file diff --git a/README.md b/README.md index 128ffcc15..0dcad615b 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ cd ubiquibot yarn yarn build (to compile your changes) -yarn build --watch (to locally auto compile your changes) +yarn build --watch (to locally auto compile your changes) yarn start:watch @@ -54,9 +54,9 @@ yarn start:watch - `WEBHOOK_PROXY_URL`: (required) should be automatically filled when you install Ubiquibot - `WEBHOOK_SECRET`: (required) should be automatically filled when the app is installed -`APP_ID` and `PRIVATE_KEY` are [here](https://t.me/c/1588400061/1627) for core team developers to use. +`APP_ID` and `APP_PRIVATE_KEY` are [here](https://t.me/c/1588400061/1627) for core team developers to use. -If you are an external developer, `APP_ID`and `PRIVATE_KEY` are automatically generated when you install the app on your repository. +If you are an external developer, `APP_ID`and `APP_PRIVATE_KEY` are automatically generated when you install the app on your repository. ## How to run locally @@ -258,7 +258,7 @@ DISQUALIFY_TIME="7 days" // 7 days - in another instance run `yarn start:watch` (runs the bot locally) 5. Open `http://localhost:3000` and follow instructions to add the bot to one of your repositories. -At this point the `.env` files auto-fill the empty fields (`PRIVATE_KEY` and `APP_ID`) if it is not previously filled. +At this point the `.env` files auto-fill the empty fields (`APP_PRIVATE_KEY` and `APP_ID`) if it is not previously filled. Now you can make changes to the repository on GitHub (e.g. add a bounty) and the bot should react. 6. After adding the bot (as a installed app) to your github you will need to restart the aforemention yarn start:watch so CTRL-C to stop the node daemon and `yarn start:watch` again diff --git a/src/types/configuration-types.ts b/src/types/configuration-types.ts index e2e113744..ee4feb8d1 100644 --- a/src/types/configuration-types.ts +++ b/src/types/configuration-types.ts @@ -47,13 +47,13 @@ export function stringDuration(options?: StringOptions) { } const envConfigSchema = T.Object({ - WEBHOOK_PROXY_URL: T.String({ format: "uri" }), + WEBHOOK_PROXY_URL: T.Optional(T.String({ format: "uri" })), // optional for production LOG_LEVEL: T.Enum(LogLevel, { default: LogLevel.DEBUG }), LOG_RETRY_LIMIT: T.Number({ default: 8 }), SUPABASE_URL: T.String({ format: "uri" }), SUPABASE_KEY: T.String(), X25519_PRIVATE_KEY: T.String(), - PRIVATE_KEY: T.String(), + APP_PRIVATE_KEY: T.String(), APP_ID: T.Number(), });