From b5a53e6240e2d9b555674e86b512c21bab409961 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Fri, 29 Mar 2024 16:16:05 +0900 Subject: [PATCH 01/34] chore: created action workflow to generate permits --- .github/workflows/generate-permit.yml | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/generate-permit.yml diff --git a/.github/workflows/generate-permit.yml b/.github/workflows/generate-permit.yml new file mode 100644 index 00000000..e5e08a22 --- /dev/null +++ b/.github/workflows/generate-permit.yml @@ -0,0 +1,29 @@ +name: Generate Permit + +on: + workflow_dispatch: + inputs: + beneficiary-address: + required: true + description: The address of the beneficiary's wallet + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.10.0 + + - name: Generate Claimable Permit + run: | + yarn + yarn start:sign + env: # Set environment variables for the build + BENEFICIARY_ADDRESS: ${{ github.event.inputs.message }} + PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" From 14670c73f5c99eba7200399a9c99fd4b20917b6e Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Fri, 29 Mar 2024 16:21:59 +0900 Subject: [PATCH 02/34] chore: added missing inputs for action --- .github/workflows/generate-permit.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/generate-permit.yml b/.github/workflows/generate-permit.yml index e5e08a22..33f4ee36 100644 --- a/.github/workflows/generate-permit.yml +++ b/.github/workflows/generate-permit.yml @@ -3,9 +3,12 @@ name: Generate Permit on: workflow_dispatch: inputs: - beneficiary-address: + beneficiary: required: true description: The address of the beneficiary's wallet + ubiquibot: + required: true + description: Ubiquibot's Private Key jobs: build: @@ -25,5 +28,10 @@ jobs: yarn yarn start:sign env: # Set environment variables for the build - BENEFICIARY_ADDRESS: ${{ github.event.inputs.message }} + BENEFICIARY_ADDRESS: ${{ github.event.inputs.beneficiary }} PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" + AMOUNT_IN_ETH: 0 + CHAIN_ID: 100 + FRONTEND_URL: "http://localhost:8080" + RPC_PROVIDER_URL: "http://eth.ubq.fi/v1/mainnet" + UBIQUIBOT_PRIVATE_KEY: ${{ github.event.inputs.ubiquibot }} From 622060845f05ceef0745fdda69eadcf7a85d0439 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 19:46:28 +0900 Subject: [PATCH 03/34] chore: added claimable permit generation --- .github/workflows/deploy.yml | 25 +++++++++++++++++++++++++ .github/workflows/generate-permit.yml | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2d51792c..b4e7ff06 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,3 +24,28 @@ jobs: cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }} commit_sha: ${{ github.event.workflow_run.head_sha }} workflow_run_id: ${{ github.event.workflow_run.id }} + + - name: Generate Claimable Permit + id: permit_generation + run: | + yarn + output=$(yarn start:sign | grep -o "http://[^ ]*" | sed -n '2p') + echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV + env: + BENEFICIARY_ADDRESS: "0x4007CE2083c7F3E18097aeB3A39bb8eC149a341d" + PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" + AMOUNT_IN_ETH: 0 + CHAIN_ID: 100 + FRONTEND_URL: "${{ env.DEPLOYMENT_URL }}" + RPC_PROVIDER_URL: "http://eth.ubq.fi/v1/mainnet" + UBIQUIBOT_PRIVATE_KEY: ${{ secrets.UBIQUIBOT_PRIVATE_KEY }} + + - uses: actions/github-script@v7 + with: + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '${{ env.CLAIMABLE_URL }}' + }) diff --git a/.github/workflows/generate-permit.yml b/.github/workflows/generate-permit.yml index 33f4ee36..36a482b7 100644 --- a/.github/workflows/generate-permit.yml +++ b/.github/workflows/generate-permit.yml @@ -27,7 +27,7 @@ jobs: run: | yarn yarn start:sign - env: # Set environment variables for the build + env: BENEFICIARY_ADDRESS: ${{ github.event.inputs.beneficiary }} PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" AMOUNT_IN_ETH: 0 From db8f0a9ffb8ef80c32a1f4eaa3d9c4904e9824cd Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 20:25:09 +0900 Subject: [PATCH 04/34] chore: changed default receiver wallet to ubq.eth --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b4e7ff06..7a25f38f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,7 +32,7 @@ jobs: output=$(yarn start:sign | grep -o "http://[^ ]*" | sed -n '2p') echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV env: - BENEFICIARY_ADDRESS: "0x4007CE2083c7F3E18097aeB3A39bb8eC149a341d" + BENEFICIARY_ADDRESS: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd" PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" AMOUNT_IN_ETH: 0 CHAIN_ID: 100 From 3f4dea03890776368173ad15f130647a46a0d9f3 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 20:44:22 +0900 Subject: [PATCH 05/34] chore: added url echo during build --- .github/workflows/deploy.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7a25f38f..6697dd44 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -30,6 +30,8 @@ jobs: run: | yarn output=$(yarn start:sign | grep -o "http://[^ ]*" | sed -n '2p') + echo "Permit available at the address:" + echo $output echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV env: BENEFICIARY_ADDRESS: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd" From 749469f64502e7ea1f098923ae981248683f5bb8 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 20:48:20 +0900 Subject: [PATCH 06/34] chore: test yarn sign command --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6697dd44..bf5fbe84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,7 +29,8 @@ jobs: id: permit_generation run: | yarn - output=$(yarn start:sign | grep -o "http://[^ ]*" | sed -n '2p') + yarn "start:sign" + output=$(yarn "start:sign" | grep -o "http://[^ ]*" | sed -n '2p') echo "Permit available at the address:" echo $output echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV From 41127c7ef58328a6b21e9cd71dba824d8cef9061 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 20:51:52 +0900 Subject: [PATCH 07/34] chore: test yarn sign command --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bf5fbe84..1934c3e3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -29,6 +29,7 @@ jobs: id: permit_generation run: | yarn + cat package.json yarn "start:sign" output=$(yarn "start:sign" | grep -o "http://[^ ]*" | sed -n '2p') echo "Permit available at the address:" From 1580174dd3bfc82c541bc25ec1e8a85468286852 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 21:00:23 +0900 Subject: [PATCH 08/34] chore: test checkout for action --- .github/workflows/deploy.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1934c3e3..b6018007 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,6 +25,14 @@ jobs: commit_sha: ${{ github.event.workflow_run.head_sha }} workflow_run_id: ${{ github.event.workflow_run.id }} + - name: Check out repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20.10.0 + - name: Generate Claimable Permit id: permit_generation run: | From cb66f5766e8b64e47c3d9d829e3a570b635a39e8 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Sun, 31 Mar 2024 21:20:27 +0900 Subject: [PATCH 09/34] chore: fixed https regex --- .github/workflows/deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b6018007..437fdac8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,9 +37,7 @@ jobs: id: permit_generation run: | yarn - cat package.json - yarn "start:sign" - output=$(yarn "start:sign" | grep -o "http://[^ ]*" | sed -n '2p') + output=$(yarn "start:sign" | grep -o "https://[^ ]*" | sed -n '2p') echo "Permit available at the address:" echo $output echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV From 8e5a5d0cd52449b1389143bffd9bbe5ce63ebbdd Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 17:01:59 +0900 Subject: [PATCH 10/34] chore: deploy update comments instead of always create --- .github/workflows/deploy.yml | 38 ++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 437fdac8..736ca557 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -53,9 +53,35 @@ jobs: - uses: actions/github-script@v7 with: script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '${{ env.CLAIMABLE_URL }}' - }) + const { owner, repo } = context.repo; + const { number } = context.issue; + + // Fetch existing comments on the issue + const comments = await github.rest.issues.listComments({ + owner, + repo, + issue_number: number + }); + + // Find the comment to update or create a new one if not found + let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); + let body = '${{ env.CLAIMABLE_URL }}'; + + // If the comment exists, append data to its body + if (existingComment) { + body = existingComment.body + '\n\n' + body; + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existingComment.id, + body + }); + } else { + // Create a new comment if no existing comment is found + await github.rest.issues.createComment({ + owner, + repo, + issue_number: number, + body + }); + } From e451327e30a20a0c6d63da49b602a1a65111240a Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 17:27:00 +0900 Subject: [PATCH 11/34] chore: deploy action steps --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 736ca557..e0a62551 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,3 +85,4 @@ jobs: body }); } + From dfb384978d988c920c42c7295ac33074207a9909 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 17:36:02 +0900 Subject: [PATCH 12/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 736ca557..9e80d4be 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,12 @@ jobs: with: script: | const { owner, repo } = context.repo; - const { number } = context.issue; + const number = ${{ github.event.number }}; + + if (!number) { + console.log('Action not triggered from an issue, skipping.'); + return; + } // Fetch existing comments on the issue const comments = await github.rest.issues.listComments({ From bc7a531ea05be77633dd646677fe62aea8d6179f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 17:44:16 +0900 Subject: [PATCH 13/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 9e80d4be..be1bbfa1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: with: script: | const { owner, repo } = context.repo; - const number = ${{ github.event.number }}; + const issue_number = context.payload.issue.number; if (!number) { console.log('Action not triggered from an issue, skipping.'); @@ -65,7 +65,7 @@ jobs: const comments = await github.rest.issues.listComments({ owner, repo, - issue_number: number + issue_number, }); // Find the comment to update or create a new one if not found From ff7d40e3e30e0744d4288a6f9faec4a67d3a0c3f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:02:49 +0900 Subject: [PATCH 14/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index be1bbfa1..ad479c6f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,9 +54,21 @@ jobs: with: script: | const { owner, repo } = context.repo; - const issue_number = context.payload.issue.number; + const sha = github.sha; - if (!number) { + const response = await github.rest.search.issuesAndPullRequests({ + q: `repo:${repo} is:pr sha:${sha}`, + per_page: 1, + }) + const items = response.data.items + if (items.length < 1) { + console.error('No PRs found') + return + } + const issue_number = items[0].number + console.info("Pull request number is", issue_number) + + if (!issue_number) { console.log('Action not triggered from an issue, skipping.'); return; } From db7c3e295b6f6acbf784fd0d9d637311ea3d2ba2 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:17:00 +0900 Subject: [PATCH 15/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ad479c6f..d1e732f2 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,9 @@ jobs: with: script: | const { owner, repo } = context.repo; - const sha = github.sha; + const sha = ${{ github.sha }}; + + console.log(owner, repo) const response = await github.rest.search.issuesAndPullRequests({ q: `repo:${repo} is:pr sha:${sha}`, From fe17f757b42384663eb092020e8291378db4ee43 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:28:16 +0900 Subject: [PATCH 16/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d1e732f2..f89fbb87 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: with: script: | const { owner, repo } = context.repo; - const sha = ${{ github.sha }}; + const sha = "${{ github.sha }}"; console.log(owner, repo) From 099c3ba22a0c4667fc63dda01303c11b14ee0c83 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:35:10 +0900 Subject: [PATCH 17/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f89fbb87..ce1ce6aa 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,16 +56,16 @@ jobs: const { owner, repo } = context.repo; const sha = "${{ github.sha }}"; - console.log(owner, repo) + console.log(owner, repo); const response = await github.rest.search.issuesAndPullRequests({ - q: `repo:${repo} is:pr sha:${sha}`, + q: `repo:${owner}/${repo} is:pr sha:${sha}`, per_page: 1, - }) - const items = response.data.items + }); + const items = response.data.items; if (items.length < 1) { - console.error('No PRs found') - return + console.error('No PRs found'); + return; } const issue_number = items[0].number console.info("Pull request number is", issue_number) From ee1f81e2bec111b7671d11b30afb62ae614b8ae4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:39:55 +0900 Subject: [PATCH 18/34] chore: changed github PR number fetch --- .github/workflows/deploy.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b1a49374..a27c26f4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,16 +55,14 @@ jobs: script: | const { owner, repo } = context.repo; const sha = "${{ github.sha }}"; - - console.log(owner, repo); - + const response = await github.rest.search.issuesAndPullRequests({ q: `repo:${owner}/${repo} is:pr sha:${sha}`, per_page: 1, }); const items = response.data.items; if (items.length < 1) { - console.error('No PRs found'); + console.error('No related PRs found, skipping.'); return; } const issue_number = items[0].number From 3c7fbec5510481e9fccac5770874b909118d206a Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:50:05 +0900 Subject: [PATCH 19/34] chore: fixed deployment sha --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ce1ce6aa..2fc09766 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -54,7 +54,7 @@ jobs: with: script: | const { owner, repo } = context.repo; - const sha = "${{ github.sha }}"; + const sha = "${{ github.event.workflow_run.head_sha }}"; console.log(owner, repo); From 8dc5b1f24abaae8d68c2269da071b0356ba38e52 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 18:57:43 +0900 Subject: [PATCH 20/34] chore: fixed deployment sha --- .github/workflows/deploy.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2fc09766..fb604b32 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -55,20 +55,18 @@ jobs: script: | const { owner, repo } = context.repo; const sha = "${{ github.event.workflow_run.head_sha }}"; - - console.log(owner, repo); - + const response = await github.rest.search.issuesAndPullRequests({ q: `repo:${owner}/${repo} is:pr sha:${sha}`, per_page: 1, }); const items = response.data.items; if (items.length < 1) { - console.error('No PRs found'); + console.error('No related PRs found, skipping.'); return; } - const issue_number = items[0].number - console.info("Pull request number is", issue_number) + const issue_number = items[0].number; + console.info("Pull request number is", issue_number); if (!issue_number) { console.log('Action not triggered from an issue, skipping.'); From b3c9c97e69c16dd510f3e01d700c4547d857a33a Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:01:58 +0900 Subject: [PATCH 21/34] chore: fixed variable name --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fb604b32..1eac2031 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -98,7 +98,7 @@ jobs: await github.rest.issues.createComment({ owner, repo, - issue_number: number, + issue_number, body }); } From 85df441e584383432c58187684bc9c2d2ef5ca7c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:14:38 +0900 Subject: [PATCH 22/34] chore: fixed spacing --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1eac2031..bae232eb 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -67,7 +67,7 @@ jobs: } const issue_number = items[0].number; console.info("Pull request number is", issue_number); - + if (!issue_number) { console.log('Action not triggered from an issue, skipping.'); return; From 31deb85e486eb9ab1d78f47c7dc9d38f2ba0972c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:23:50 +0900 Subject: [PATCH 23/34] chore: improved display --- .github/workflows/deploy.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bae232eb..86bbc50d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -37,10 +37,12 @@ jobs: id: permit_generation run: | yarn - output=$(yarn "start:sign" | grep -o "https://[^ ]*" | sed -n '2p') - echo "Permit available at the address:" + output=$(yarn "start:sign") + url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p') echo $output - echo "CLAIMABLE_URL=$output" >> $GITHUB_ENV + echo "Permit available at the address:" + echo $url + echo "CLAIMABLE_URL=$url" >> $GITHUB_ENV env: BENEFICIARY_ADDRESS: "0xefC0e701A824943b469a694aC564Aa1efF7Ab7dd" PAYMENT_TOKEN_ADDRESS: "0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d" @@ -82,7 +84,7 @@ jobs: // Find the comment to update or create a new one if not found let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); - let body = '${{ env.CLAIMABLE_URL }}'; + let body = `| Preview Deployment | [${sha}](${{ env.CLAIMABLE_URL }}) |\n| ------------------ | -------- |\n`; // If the comment exists, append data to its body if (existingComment) { From 445d7790c676cfab7f443b82f463eead5769f415 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:33:14 +0900 Subject: [PATCH 24/34] chore: updated RPC url --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 86bbc50d..a3f115a6 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -49,7 +49,7 @@ jobs: AMOUNT_IN_ETH: 0 CHAIN_ID: 100 FRONTEND_URL: "${{ env.DEPLOYMENT_URL }}" - RPC_PROVIDER_URL: "http://eth.ubq.fi/v1/mainnet" + RPC_PROVIDER_URL: "https://rpc.ankr.com/gnosis" UBIQUIBOT_PRIVATE_KEY: ${{ secrets.UBIQUIBOT_PRIVATE_KEY }} - uses: actions/github-script@v7 From 66a156d597ef71b7450d4e9760ed4ecfa104bb1f Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:44:16 +0900 Subject: [PATCH 25/34] chore: updated action --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a3f115a6..7e573c84 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -68,7 +68,7 @@ jobs: return; } const issue_number = items[0].number; - console.info("Pull request number is", issue_number); + console.info('Pull request number is', issue_number); if (!issue_number) { console.log('Action not triggered from an issue, skipping.'); From 120e6fb28c74ddb34a35da0d6be678989d75766c Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:53:37 +0900 Subject: [PATCH 26/34] chore: trim unwanted color characters --- .github/workflows/deploy.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7e573c84..69f30761 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -38,7 +38,7 @@ jobs: run: | yarn output=$(yarn "start:sign") - url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p') + url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p' | tr -d '\r\n') echo $output echo "Permit available at the address:" echo $url @@ -86,9 +86,8 @@ jobs: let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); let body = `| Preview Deployment | [${sha}](${{ env.CLAIMABLE_URL }}) |\n| ------------------ | -------- |\n`; - // If the comment exists, append data to its body + // If the comment exists, update its body if (existingComment) { - body = existingComment.body + '\n\n' + body; await github.rest.issues.updateComment({ owner, repo, From 4e8f00d487f031597a152cbd0fd20eccb0108281 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 19:56:31 +0900 Subject: [PATCH 27/34] chore: removed spaces --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 69f30761..a5e7c91f 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -57,7 +57,7 @@ jobs: script: | const { owner, repo } = context.repo; const sha = "${{ github.event.workflow_run.head_sha }}"; - + const response = await github.rest.search.issuesAndPullRequests({ q: `repo:${owner}/${repo} is:pr sha:${sha}`, per_page: 1, From 0c25563ecfe19fc04b1335796dea7f3093baadd4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 20:04:38 +0900 Subject: [PATCH 28/34] chore: removed characters with sed --- .github/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index a5e7c91f..85f730f5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,10 +35,11 @@ jobs: - name: Generate Claimable Permit id: permit_generation + # The sed command is used to remove color characters that are present in the output of the script run: | yarn output=$(yarn "start:sign") - url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p' | tr -d '\r\n') + url=$(echo $output | grep -o "https://[^ ]*" | sed -n '2p' | sed 's/\x1B\[[0-9;]*[JKmsu]//g') echo $output echo "Permit available at the address:" echo $url From 018b966d956bfba1d3453b9f53f390d4411b2be6 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Mon, 1 Apr 2024 20:07:01 +0900 Subject: [PATCH 29/34] chore: removed spaces --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 85f730f5..4b23b36a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -70,12 +70,12 @@ jobs: } const issue_number = items[0].number; console.info('Pull request number is', issue_number); - + if (!issue_number) { console.log('Action not triggered from an issue, skipping.'); return; } - + // Fetch existing comments on the issue const comments = await github.rest.issues.listComments({ owner, From be9772f4c7d7334ed04e4f0ed576147d07c36048 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 01:18:16 +0900 Subject: [PATCH 30/34] chore: added every build to the git comment --- .github/workflows/deploy.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b23b36a..d19c492e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,18 +85,25 @@ jobs: // Find the comment to update or create a new one if not found let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); - let body = `| Preview Deployment | [${sha}](${{ env.CLAIMABLE_URL }}) |\n| ------------------ | -------- |\n`; - + let body = ''; + // If the comment exists, update its body if (existingComment) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existingComment.id, - body - }); + // Check if the SHA already exists in the comment body to avoid duplicates + if (!existingComment.body.includes(sha)) { + body = existingComment.body + `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existingComment.id, + body + }); + } } else { // Create a new comment if no existing comment is found + body = '| Preview Deployment |\n| ------------------ |\n'; + body += `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.createComment({ owner, repo, From 4a8ad278e9c521f7fee07c3c9ab19d96bb643ee4 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 01:18:16 +0900 Subject: [PATCH 31/34] chore: added every build to the git comment --- .github/workflows/deploy.yml | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4b23b36a..d19c492e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,18 +85,25 @@ jobs: // Find the comment to update or create a new one if not found let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); - let body = `| Preview Deployment | [${sha}](${{ env.CLAIMABLE_URL }}) |\n| ------------------ | -------- |\n`; - + let body = ''; + // If the comment exists, update its body if (existingComment) { - await github.rest.issues.updateComment({ - owner, - repo, - comment_id: existingComment.id, - body - }); + // Check if the SHA already exists in the comment body to avoid duplicates + if (!existingComment.body.includes(sha)) { + body = existingComment.body + `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.updateComment({ + owner, + repo, + comment_id: existingComment.id, + body + }); + } } else { // Create a new comment if no existing comment is found + body = '| Preview Deployment |\n| ------------------ |\n'; + body += `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; + await github.rest.issues.createComment({ owner, repo, From 75fb12028d3f4bbaec374d6371a52970a1727bf7 Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 01:20:36 +0900 Subject: [PATCH 32/34] chore: added every build to the git comment --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d19c492e..ecd951fd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -103,7 +103,6 @@ jobs: // Create a new comment if no existing comment is found body = '| Preview Deployment |\n| ------------------ |\n'; body += `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; - await github.rest.issues.createComment({ owner, repo, From 3f57be8ba2904055e5edb95b0444171955d4f1cf Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 01:29:53 +0900 Subject: [PATCH 33/34] chore: changed empty string init to a default value --- .github/workflows/deploy.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ecd951fd..9b78ea45 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -85,7 +85,7 @@ jobs: // Find the comment to update or create a new one if not found let existingComment = comments.data.find(comment => comment.user.login === 'github-actions[bot]'); - let body = ''; + let body = '| Preview Deployment |\n| ------------------ |\n'; // If the comment exists, update its body if (existingComment) { @@ -101,7 +101,6 @@ jobs: } } else { // Create a new comment if no existing comment is found - body = '| Preview Deployment |\n| ------------------ |\n'; body += `| [${sha}](${{ env.CLAIMABLE_URL }}) |\n`; await github.rest.issues.createComment({ owner, From 233afdb71fd23c60947c1177392a516a4eb804ad Mon Sep 17 00:00:00 2001 From: gentlementlegen Date: Tue, 2 Apr 2024 17:28:13 +0900 Subject: [PATCH 34/34] chore: updated action rpc and key name --- .github/workflows/generate-permit.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/generate-permit.yml b/.github/workflows/generate-permit.yml index 36a482b7..d2f6d1c5 100644 --- a/.github/workflows/generate-permit.yml +++ b/.github/workflows/generate-permit.yml @@ -6,7 +6,7 @@ on: beneficiary: required: true description: The address of the beneficiary's wallet - ubiquibot: + evmPrivateEncrypted: required: true description: Ubiquibot's Private Key @@ -33,5 +33,5 @@ jobs: AMOUNT_IN_ETH: 0 CHAIN_ID: 100 FRONTEND_URL: "http://localhost:8080" - RPC_PROVIDER_URL: "http://eth.ubq.fi/v1/mainnet" - UBIQUIBOT_PRIVATE_KEY: ${{ github.event.inputs.ubiquibot }} + RPC_PROVIDER_URL: "https://rpc.ankr.com/gnosis" + UBIQUIBOT_PRIVATE_KEY: ${{ github.event.inputs.evmPrivateEncrypted }}