From 70390b8fc7d9e28c2d10a092b6f6636492d07c38 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:20:00 +0100 Subject: [PATCH 01/32] adds workflow --- .github/workflows/weekly_clone_stats.yml | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/weekly_clone_stats.yml diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml new file mode 100644 index 0000000..63b4d52 --- /dev/null +++ b/.github/workflows/weekly_clone_stats.yml @@ -0,0 +1,68 @@ +name: Weekly Clone Stats Email + +on: + schedule: + - cron: '0 8 * * 1' # Every Monday at 08:00 UTC + +jobs: + fetch-clone-stats: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Fetch Clone Stats + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + REPO="${{ github.repository }}" + curl -s -H "Authorization: token $GITHUB_TOKEN" \ + "https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json + + - name: Upload Clone Stats + uses: actions/upload-artifact@v3 + with: + name: clone-stats + path: clone_stats.json + + send-email: + needs: fetch-clone-stats + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Download Clone Stats + uses: actions/download-artifact@v3 + with: + name: clone-stats + path: . + + - name: Parse clone stats + id: parse + run: | + COUNT=$(jq '.count' clone_stats.json) + UNIQUES=$(jq '.uniques' clone_stats.json) + echo "count=$COUNT" >> $GITHUB_OUTPUT + echo "uniques=$UNIQUES" >> $GITHUB_OUTPUT + + - name: Send email + uses: mattnotmitt/send-email@v1 + with: + smtp-server: smtp.sendgrid.net + smtp-port: 587 + secure: true + username: ${{ secrets.SMTP_USERNAME }} + password: ${{ secrets.SMTP_PASSWORD }} + from: ${{ vars.EMAIL_FROM }} + to: ${{ vars.EMAIL_TO }} + subject: šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }} + body: | + Hi, + + Here are the clone stats for *${{ github.repository }}* this week: + + šŸ” Total Clones: ${{ steps.parse.outputs.count }} + šŸ‘¤ Unique Cloners: ${{ steps.parse.outputs.uniques }} + + – GitHub Bot From 0bb3193ef08db8233d5870c3ccec98e38caed084 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:20:43 +0100 Subject: [PATCH 02/32] adds pullrequest as trigger --- .github/workflows/weekly_clone_stats.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 63b4d52..f37c46a 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -4,6 +4,10 @@ on: schedule: - cron: '0 8 * * 1' # Every Monday at 08:00 UTC + pull_request: + branches: + - main + jobs: fetch-clone-stats: runs-on: ubuntu-latest From 0658feedc93c024c83785a376437d03f30df9d06 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:25:26 +0100 Subject: [PATCH 03/32] fixes flow --- .github/workflows/weekly_clone_stats.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index f37c46a..c2dbb8e 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -1,18 +1,22 @@ name: Weekly Clone Stats Email on: + # Every Monday at 08:00 UTC schedule: - - cron: '0 8 * * 1' # Every Monday at 08:00 UTC + - cron: '0 8 * * 1' pull_request: branches: - main +permissions: + contents: read + jobs: fetch-clone-stats: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Check out code uses: actions/checkout@v3 - name: Fetch Clone Stats @@ -26,20 +30,24 @@ jobs: - name: Upload Clone Stats uses: actions/upload-artifact@v3 with: + # This is the name used to identify the artifact name: clone-stats + # File(s) or directories you want to upload as the artifact path: clone_stats.json send-email: needs: fetch-clone-stats runs-on: ubuntu-latest steps: - - name: Checkout + - name: Check out code uses: actions/checkout@v3 - name: Download Clone Stats uses: actions/download-artifact@v3 with: + # Must match the name used above in actions/upload-artifact name: clone-stats + # The path/folder where the artifact is extracted path: . - name: Parse clone stats @@ -60,7 +68,7 @@ jobs: password: ${{ secrets.SMTP_PASSWORD }} from: ${{ vars.EMAIL_FROM }} to: ${{ vars.EMAIL_TO }} - subject: šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }} + subject: "šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }}" body: | Hi, From 422a08132f3d33948b6329c6dc835627d7ec2e5c Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:26:55 +0100 Subject: [PATCH 04/32] use upload-artifact v4 --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index c2dbb8e..47ac6c6 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -28,7 +28,7 @@ jobs: "https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json - name: Upload Clone Stats - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: # This is the name used to identify the artifact name: clone-stats From 8c42332baf5de76c5cf19756916384aa0f6f7e2e Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:27:40 +0100 Subject: [PATCH 05/32] uses download-artifact v4 --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 47ac6c6..01944d8 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v3 - name: Download Clone Stats - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: # Must match the name used above in actions/upload-artifact name: clone-stats From 327a8cc048cc8f10438ddf75af9b7928351c739e Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:30:10 +0100 Subject: [PATCH 06/32] fixes email sending --- .github/workflows/weekly_clone_stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 01944d8..b9995f3 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -59,10 +59,10 @@ jobs: echo "uniques=$UNIQUES" >> $GITHUB_OUTPUT - name: Send email - uses: mattnotmitt/send-email@v1 + uses: dawidd6/action-send-mail@v3 with: - smtp-server: smtp.sendgrid.net - smtp-port: 587 + server_address: smtp.sendgrid.net + server_port: 587 secure: true username: ${{ secrets.SMTP_USERNAME }} password: ${{ secrets.SMTP_PASSWORD }} From c1d61e862f4513591c86a0a78b5fabd92ff5f254 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:34:43 +0100 Subject: [PATCH 07/32] prints result --- .github/workflows/weekly_clone_stats.yml | 46 +++++++----------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index b9995f3..af5e265 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -1,9 +1,8 @@ name: Weekly Clone Stats Email on: - # Every Monday at 08:00 UTC schedule: - - cron: '0 8 * * 1' + - cron: '0 8 * * 1' # Every Monday at 08:00 UTC pull_request: branches: @@ -19,6 +18,9 @@ jobs: - name: Check out code uses: actions/checkout@v3 + - name: Install jq + run: sudo apt-get update && sudo apt-get install -y jq + - name: Fetch Clone Stats env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -28,14 +30,12 @@ jobs: "https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json - name: Upload Clone Stats - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: - # This is the name used to identify the artifact name: clone-stats - # File(s) or directories you want to upload as the artifact path: clone_stats.json - send-email: + print-stats: needs: fetch-clone-stats runs-on: ubuntu-latest steps: @@ -43,38 +43,18 @@ jobs: uses: actions/checkout@v3 - name: Download Clone Stats - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v3 with: - # Must match the name used above in actions/upload-artifact name: clone-stats - # The path/folder where the artifact is extracted path: . - - name: Parse clone stats + - name: Print raw JSON + run: cat clone_stats.json + + - name: Parse and Print Stats id: parse run: | COUNT=$(jq '.count' clone_stats.json) UNIQUES=$(jq '.uniques' clone_stats.json) - echo "count=$COUNT" >> $GITHUB_OUTPUT - echo "uniques=$UNIQUES" >> $GITHUB_OUTPUT - - - name: Send email - uses: dawidd6/action-send-mail@v3 - with: - server_address: smtp.sendgrid.net - server_port: 587 - secure: true - username: ${{ secrets.SMTP_USERNAME }} - password: ${{ secrets.SMTP_PASSWORD }} - from: ${{ vars.EMAIL_FROM }} - to: ${{ vars.EMAIL_TO }} - subject: "šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }}" - body: | - Hi, - - Here are the clone stats for *${{ github.repository }}* this week: - - šŸ” Total Clones: ${{ steps.parse.outputs.count }} - šŸ‘¤ Unique Cloners: ${{ steps.parse.outputs.uniques }} - - – GitHub Bot + echo "Total Clones: $COUNT" + echo "Unique Cloners: $UNIQUES" From 71e3f5404607c8fd470a8af8a3fc1417ba34d897 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:35:18 +0100 Subject: [PATCH 08/32] prints result --- .github/workflows/weekly_clone_stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index af5e265..89b5f11 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -30,7 +30,7 @@ jobs: "https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json - name: Upload Clone Stats - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: clone-stats path: clone_stats.json @@ -43,7 +43,7 @@ jobs: uses: actions/checkout@v3 - name: Download Clone Stats - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: clone-stats path: . From 88003472ee798a1a3ca6ca747f8d0606d7611c97 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:44:20 +0100 Subject: [PATCH 09/32] removes PR triggering --- .github/workflows/weekly_clone_stats.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 89b5f11..3748502 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -4,10 +4,6 @@ on: schedule: - cron: '0 8 * * 1' # Every Monday at 08:00 UTC - pull_request: - branches: - - main - permissions: contents: read @@ -23,7 +19,7 @@ jobs: - name: Fetch Clone Stats env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.TOKEN }} run: | REPO="${{ github.repository }}" curl -s -H "Authorization: token $GITHUB_TOKEN" \ From da29073b88115e3369f45e02a6cb111909110377 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:48:12 +0100 Subject: [PATCH 10/32] fixes clone number issue --- .github/workflows/weekly_clone_stats.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 3748502..6035441 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -22,8 +22,12 @@ jobs: GITHUB_TOKEN: ${{ secrets.TOKEN }} run: | REPO="${{ github.repository }}" - curl -s -H "Authorization: token $GITHUB_TOKEN" \ - "https://api.github.com/repos/$REPO/traffic/clones" > clone_stats.json + OWNER="${{ github.repository_owner }}" + curl -L \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer " \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + https://api.github.com/repos/$OWNER/$REPO/traffic/clones > clone_stats.json - name: Upload Clone Stats uses: actions/upload-artifact@v4 From 399f54100ef880cb4981237531cef081efad6bfa Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:50:08 +0100 Subject: [PATCH 11/32] adds trigger --- .github/workflows/weekly_clone_stats.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 6035441..e77a674 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -4,6 +4,10 @@ on: schedule: - cron: '0 8 * * 1' # Every Monday at 08:00 UTC + pull_request: + branches: + - main + permissions: contents: read From 78baacf000dbc601c926a8a8a72abd6062de807c Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:51:40 +0100 Subject: [PATCH 12/32] fixes link --- .github/workflows/weekly_clone_stats.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index e77a674..91d8e9e 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -18,20 +18,16 @@ jobs: - name: Check out code uses: actions/checkout@v3 - - name: Install jq - run: sudo apt-get update && sudo apt-get install -y jq - - name: Fetch Clone Stats env: GITHUB_TOKEN: ${{ secrets.TOKEN }} run: | REPO="${{ github.repository }}" - OWNER="${{ github.repository_owner }}" curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer " \ -H "X-GitHub-Api-Version: 2022-11-28" \ - https://api.github.com/repos/$OWNER/$REPO/traffic/clones > clone_stats.json + https://api.github.com/repos/$REPO/traffic/clones > clone_stats.json - name: Upload Clone Stats uses: actions/upload-artifact@v4 From 06b17eebb46567931e4ff86201c33418576f54bb Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:53:25 +0100 Subject: [PATCH 13/32] fixes credentials --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 91d8e9e..71345b6 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -20,7 +20,7 @@ jobs: - name: Fetch Clone Stats env: - GITHUB_TOKEN: ${{ secrets.TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | REPO="${{ github.repository }}" curl -L \ From e52436df60772046dba2a34f02d4a6ab2a063530 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 16:55:02 +0100 Subject: [PATCH 14/32] fixes credentials --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 71345b6..515f2e5 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -25,7 +25,7 @@ jobs: REPO="${{ github.repository }}" curl -L \ -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer " \ + -H "Authorization: Bearer $GITHUB_TOKEN" \ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/$REPO/traffic/clones > clone_stats.json From a26b4553b7c855f7c4b1375e1b1f25f0d6121ec9 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 17:38:07 +0100 Subject: [PATCH 15/32] fixes credentials --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 515f2e5..016e6c0 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -20,7 +20,7 @@ jobs: - name: Fetch Clone Stats env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} run: | REPO="${{ github.repository }}" curl -L \ From f230edcf8f87c7b1e4c78a23e6a9afa270d875a6 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 17:43:50 +0100 Subject: [PATCH 16/32] adds back email sending --- .github/workflows/weekly_clone_stats.yml | 30 +++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 016e6c0..b8d19c0 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -51,10 +51,34 @@ jobs: - name: Print raw JSON run: cat clone_stats.json - - name: Parse and Print Stats + - name: Parse clone stats id: parse run: | COUNT=$(jq '.count' clone_stats.json) UNIQUES=$(jq '.uniques' clone_stats.json) - echo "Total Clones: $COUNT" - echo "Unique Cloners: $UNIQUES" + echo "count=$COUNT" >> "$GITHUB_OUTPUT" + echo "uniques=$UNIQUES" >> "$GITHUB_OUTPUT" + + - name: Send email + uses: dawidd6/action-send-mail@v3 + with: + # Replace with your SMTP server, port, and credentials + server_address: smtp.sendgrid.net + server_port: 587 + username: ${{ secrets.SMTP_USERNAME }} + password: ${{ secrets.SMTP_PASSWORD }} + subject: "šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }}" + to: ${{ vars.EMAIL_TO }} + from: ${{ vars.EMAIL_FROM }} + # "text/html" is optional if you want to send as HTML + content_type: text/plain + secure: true + body: | + Hi, + + Here are the clone stats for *${{ github.repository }}* this week: + + šŸ” Total Clones: ${{ steps.parse.outputs.count }} + šŸ‘¤ Unique Cloners: ${{ steps.parse.outputs.uniques }} + + – GitHub Bot \ No newline at end of file From 4a6bbe680c3f6083fe89870786b33f568fd696c7 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 17:45:39 +0100 Subject: [PATCH 17/32] removes not needed step --- .github/workflows/weekly_clone_stats.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index b8d19c0..1785909 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -48,9 +48,6 @@ jobs: name: clone-stats path: . - - name: Print raw JSON - run: cat clone_stats.json - - name: Parse clone stats id: parse run: | From 5c7d1f290d800effece5491aec858d6eede532b1 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 17:59:41 +0100 Subject: [PATCH 18/32] add email sending --- .github/sendgrid.js | 23 +++++++++++++++++ .github/workflows/weekly_clone_stats.yml | 32 +++++++----------------- 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 .github/sendgrid.js diff --git a/.github/sendgrid.js b/.github/sendgrid.js new file mode 100644 index 0000000..d14b49c --- /dev/null +++ b/.github/sendgrid.js @@ -0,0 +1,23 @@ +#! /usr/bin/env node + +const sgMail = require('@sendgrid/mail'); +sgMail.setApiKey(process.env.SENDGRID_API_KEY); + +const msg = { + to: process.env.TO, + from: process.env.FROM, + subject: "šŸ“Š Weekly GitHub Clone Stats for example-flutter-passkeys", + text: "Hi,\n" + + "\n" + + "Here are the clone stats for example-flutter-passkeys this week:\n" + + "\n" + + `šŸ” Total Clones: ${process.env.COUNT}\n` + + `šŸ‘¤ Unique Cloners: ${process.env.UNIQUE_COUNT}\n` + + "\n" + + "– GitHub Bot" +}; + +sgMail + .send(msg) + .then(() => console.log('Mail sent successfully')) + .catch(error => console.error(error.toString())); \ No newline at end of file diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 1785909..0e089de 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -56,26 +56,12 @@ jobs: echo "count=$COUNT" >> "$GITHUB_OUTPUT" echo "uniques=$UNIQUES" >> "$GITHUB_OUTPUT" - - name: Send email - uses: dawidd6/action-send-mail@v3 - with: - # Replace with your SMTP server, port, and credentials - server_address: smtp.sendgrid.net - server_port: 587 - username: ${{ secrets.SMTP_USERNAME }} - password: ${{ secrets.SMTP_PASSWORD }} - subject: "šŸ“Š Weekly GitHub Clone Stats for ${{ github.repository }}" - to: ${{ vars.EMAIL_TO }} - from: ${{ vars.EMAIL_FROM }} - # "text/html" is optional if you want to send as HTML - content_type: text/plain - secure: true - body: | - Hi, - - Here are the clone stats for *${{ github.repository }}* this week: - - šŸ” Total Clones: ${{ steps.parse.outputs.count }} - šŸ‘¤ Unique Cloners: ${{ steps.parse.outputs.uniques }} - - – GitHub Bot \ No newline at end of file + - name: SendGrid + uses: peter-evans/sendgrid-action@v1 + env: + SENDGRID_API_KEY: ${{ secrets.SENDGRID_KEY }} + SCRIPT_FILEPATH: ../sendgrid.js + FROM: ${{vars.EMAIL_FROM}} + TO: ${{vars.EMAIL_TO}} + COUNT: ${{ steps.parse.outputs.count }} + UNIQUE_COUNT: ${{ steps.parse.outputs.uniques }} \ No newline at end of file From 235261b3d6459739d00013006dc890a51100b1f9 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Mon, 24 Mar 2025 18:01:20 +0100 Subject: [PATCH 19/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 0e089de..0091b08 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -60,7 +60,6 @@ jobs: uses: peter-evans/sendgrid-action@v1 env: SENDGRID_API_KEY: ${{ secrets.SENDGRID_KEY }} - SCRIPT_FILEPATH: ../sendgrid.js FROM: ${{vars.EMAIL_FROM}} TO: ${{vars.EMAIL_TO}} COUNT: ${{ steps.parse.outputs.count }} From ae9f9760d24de2097125aab8111d2eeb11372910 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:41:43 +0100 Subject: [PATCH 20/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 26 ++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 0091b08..537f884 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -56,11 +56,21 @@ jobs: echo "count=$COUNT" >> "$GITHUB_OUTPUT" echo "uniques=$UNIQUES" >> "$GITHUB_OUTPUT" - - name: SendGrid - uses: peter-evans/sendgrid-action@v1 - env: - SENDGRID_API_KEY: ${{ secrets.SENDGRID_KEY }} - FROM: ${{vars.EMAIL_FROM}} - TO: ${{vars.EMAIL_TO}} - COUNT: ${{ steps.parse.outputs.count }} - UNIQUE_COUNT: ${{ steps.parse.outputs.uniques }} \ No newline at end of file + - name: Send custom email + run: | + ENCODED_AUTH=$(echo -n "apiKey:${{ secrets.SENDGRID_KEY }}" | base64) + + curl -X POST https://api.sendgrid.com/v3/mail/send \ + -H "Authorization: Basic $ENCODED_AUTH" \ + -H "Content-Type: application/json" \ + -d '{ + "personalizations": [{ + "to": [{"email": "mohamed.amine.hamdouni@corbado.com"}], + "subject": "Hello from GitHub Actions" + }], + "from": {"email": "test@corbado.com"}, + "content": [{ + "type": "text/plain", + "value": "This is a custom body sent using base64 auth." + }] + }' \ No newline at end of file From 05a49a32de2e180553e45154109c486be5954833 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:46:18 +0100 Subject: [PATCH 21/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 537f884..89ea4d5 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -58,7 +58,8 @@ jobs: - name: Send custom email run: | - ENCODED_AUTH=$(echo -n "apiKey:${{ secrets.SENDGRID_KEY }}" | base64) + USERNAME=$(echo -n "apikey" | base64) + ENCODED_AUTH=$(echo -n "$USERNAME:${{ secrets.SENDGRID_KEY }}" | base64) curl -X POST https://api.sendgrid.com/v3/mail/send \ -H "Authorization: Basic $ENCODED_AUTH" \ From 40f9f987a1da87672e85b4dde9f707d2b79c6805 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:48:09 +0100 Subject: [PATCH 22/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 89ea4d5..25cc796 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -58,8 +58,7 @@ jobs: - name: Send custom email run: | - USERNAME=$(echo -n "apikey" | base64) - ENCODED_AUTH=$(echo -n "$USERNAME:${{ secrets.SENDGRID_KEY }}" | base64) + ENCODED_AUTH=${{ secrets.SENDGRID_KEY }} curl -X POST https://api.sendgrid.com/v3/mail/send \ -H "Authorization: Basic $ENCODED_AUTH" \ From 510b991b5bb1193eeae9d6a3e96b760eccfe4311 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:49:14 +0100 Subject: [PATCH 23/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 25cc796..d1eff21 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -61,7 +61,7 @@ jobs: ENCODED_AUTH=${{ secrets.SENDGRID_KEY }} curl -X POST https://api.sendgrid.com/v3/mail/send \ - -H "Authorization: Basic $ENCODED_AUTH" \ + -H "Authorization: Bearer $ENCODED_AUTH" \ -H "Content-Type: application/json" \ -d '{ "personalizations": [{ From 2e81c78ec22f4c4b841844fc7008c2a0bda02ad2 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:54:26 +0100 Subject: [PATCH 24/32] add email sending --- .github/sendgrid.js | 23 ----------------------- .github/workflows/weekly_clone_stats.yml | 13 +++++++++---- 2 files changed, 9 insertions(+), 27 deletions(-) delete mode 100644 .github/sendgrid.js diff --git a/.github/sendgrid.js b/.github/sendgrid.js deleted file mode 100644 index d14b49c..0000000 --- a/.github/sendgrid.js +++ /dev/null @@ -1,23 +0,0 @@ -#! /usr/bin/env node - -const sgMail = require('@sendgrid/mail'); -sgMail.setApiKey(process.env.SENDGRID_API_KEY); - -const msg = { - to: process.env.TO, - from: process.env.FROM, - subject: "šŸ“Š Weekly GitHub Clone Stats for example-flutter-passkeys", - text: "Hi,\n" + - "\n" + - "Here are the clone stats for example-flutter-passkeys this week:\n" + - "\n" + - `šŸ” Total Clones: ${process.env.COUNT}\n` + - `šŸ‘¤ Unique Cloners: ${process.env.UNIQUE_COUNT}\n` + - "\n" + - "– GitHub Bot" -}; - -sgMail - .send(msg) - .then(() => console.log('Mail sent successfully')) - .catch(error => console.error(error.toString())); \ No newline at end of file diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index d1eff21..36d3f1c 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -59,18 +59,23 @@ jobs: - name: Send custom email run: | ENCODED_AUTH=${{ secrets.SENDGRID_KEY }} + FROM=${{ secrets.EMAIL_FROM }} + TO=${{ secrets.EMAIL_TO }} + COUNT=${{ steps.parse.outputs.count }} + REPOSITORY=${{ github.repository }} + UNIQUES=${{ steps.parse.outputs.uniques }} curl -X POST https://api.sendgrid.com/v3/mail/send \ -H "Authorization: Bearer $ENCODED_AUTH" \ -H "Content-Type: application/json" \ -d '{ "personalizations": [{ - "to": [{"email": "mohamed.amine.hamdouni@corbado.com"}], - "subject": "Hello from GitHub Actions" + "to": [{"email": $TO}], + "subject": "Weekly GitHub Clone Stats for $REPOSITORY" }], - "from": {"email": "test@corbado.com"}, + "from": {"email": $FROM}, "content": [{ "type": "text/plain", - "value": "This is a custom body sent using base64 auth." + "value": "Hi there! Here are the clone stats for $REPOSITORY this week:\n\nšŸ” Total Clones: $COUNT\nšŸ‘¤ Unique Cloners: $UNIQUES\n\n– GitHub Bot" }] }' \ No newline at end of file From 2baf3d4d3a649ad849e52e8d7d24dea5d70010d2 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:55:41 +0100 Subject: [PATCH 25/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 36d3f1c..8bbc8a8 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -35,7 +35,7 @@ jobs: name: clone-stats path: clone_stats.json - print-stats: + downloading-and-sending-stats: needs: fetch-clone-stats runs-on: ubuntu-latest steps: @@ -70,10 +70,10 @@ jobs: -H "Content-Type: application/json" \ -d '{ "personalizations": [{ - "to": [{"email": $TO}], + "to": [{"email": "$TO"}], "subject": "Weekly GitHub Clone Stats for $REPOSITORY" }], - "from": {"email": $FROM}, + "from": {"email": "$FROM"}, "content": [{ "type": "text/plain", "value": "Hi there! Here are the clone stats for $REPOSITORY this week:\n\nšŸ” Total Clones: $COUNT\nšŸ‘¤ Unique Cloners: $UNIQUES\n\n– GitHub Bot" From 3d9c7789f235ec62acac3b7f97b03009a2112dd7 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 08:57:27 +0100 Subject: [PATCH 26/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 8bbc8a8..9f9ffed 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -59,8 +59,8 @@ jobs: - name: Send custom email run: | ENCODED_AUTH=${{ secrets.SENDGRID_KEY }} - FROM=${{ secrets.EMAIL_FROM }} - TO=${{ secrets.EMAIL_TO }} + FROM=${{ vars.EMAIL_FROM }} + TO=${{ vars.EMAIL_TO }} COUNT=${{ steps.parse.outputs.count }} REPOSITORY=${{ github.repository }} UNIQUES=${{ steps.parse.outputs.uniques }} From b4655d430f336c75cc1a24acec81adfe32f56f81 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:03:50 +0100 Subject: [PATCH 27/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 9f9ffed..34ea0e8 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -70,10 +70,10 @@ jobs: -H "Content-Type: application/json" \ -d '{ "personalizations": [{ - "to": [{"email": "$TO"}], + "to": [{"email": $TO}], "subject": "Weekly GitHub Clone Stats for $REPOSITORY" }], - "from": {"email": "$FROM"}, + "from": {"email": $FROM}, "content": [{ "type": "text/plain", "value": "Hi there! Here are the clone stats for $REPOSITORY this week:\n\nšŸ” Total Clones: $COUNT\nšŸ‘¤ Unique Cloners: $UNIQUES\n\n– GitHub Bot" From 6aa6ca06625553b2b450496b176b078ddf1daa02 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:08:11 +0100 Subject: [PATCH 28/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 34ea0e8..1271ea8 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -73,7 +73,7 @@ jobs: "to": [{"email": $TO}], "subject": "Weekly GitHub Clone Stats for $REPOSITORY" }], - "from": {"email": $FROM}, + "from": {"email": "flutter-example@corbado.com"}, "content": [{ "type": "text/plain", "value": "Hi there! Here are the clone stats for $REPOSITORY this week:\n\nšŸ” Total Clones: $COUNT\nšŸ‘¤ Unique Cloners: $UNIQUES\n\n– GitHub Bot" From f78dc6269deb0077c7467b975c7a5b77093583d5 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:10:31 +0100 Subject: [PATCH 29/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 1271ea8..245a277 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -70,7 +70,7 @@ jobs: -H "Content-Type: application/json" \ -d '{ "personalizations": [{ - "to": [{"email": $TO}], + "to": [{"email": "$TO"}], "subject": "Weekly GitHub Clone Stats for $REPOSITORY" }], "from": {"email": "flutter-example@corbado.com"}, From 261a778a7eff2eb9f3bf0149c2926e7558935894 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:14:59 +0100 Subject: [PATCH 30/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 245a277..90f35b4 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -64,18 +64,18 @@ jobs: COUNT=${{ steps.parse.outputs.count }} REPOSITORY=${{ github.repository }} UNIQUES=${{ steps.parse.outputs.uniques }} - + curl -X POST https://api.sendgrid.com/v3/mail/send \ -H "Authorization: Bearer $ENCODED_AUTH" \ -H "Content-Type: application/json" \ - -d '{ - "personalizations": [{ - "to": [{"email": "$TO"}], - "subject": "Weekly GitHub Clone Stats for $REPOSITORY" + -d "{ + \"personalizations\": [{ + \"to\": [{\"email\": \"${TO}\"}], + \"subject\": \"Weekly GitHub Clone Stats for ${REPOSITORY}\" }], - "from": {"email": "flutter-example@corbado.com"}, - "content": [{ - "type": "text/plain", - "value": "Hi there! Here are the clone stats for $REPOSITORY this week:\n\nšŸ” Total Clones: $COUNT\nšŸ‘¤ Unique Cloners: $UNIQUES\n\n– GitHub Bot" + \"from\": {\"email\": \"${FROM}\"}, + \"content\": [{ + \"type\": \"text/plain\", + \"value\": \"Hi there! Here are the clone stats for ${REPOSITORY} this week:\n\nšŸ” Total Clones: ${COUNT}\nšŸ‘¤ Unique Cloners: ${UNIQUES}\n\n– GitHub Bot\" }] - }' \ No newline at end of file + }" \ No newline at end of file From 75738a2aca2e38e93956ebca5c14b007784b55f9 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:17:51 +0100 Subject: [PATCH 31/32] add email sending --- .github/workflows/weekly_clone_stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 90f35b4..7d62be2 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -76,6 +76,6 @@ jobs: \"from\": {\"email\": \"${FROM}\"}, \"content\": [{ \"type\": \"text/plain\", - \"value\": \"Hi there! Here are the clone stats for ${REPOSITORY} this week:\n\nšŸ” Total Clones: ${COUNT}\nšŸ‘¤ Unique Cloners: ${UNIQUES}\n\n– GitHub Bot\" + \"value\": \"Hi there! Here are the clone stats for ${REPOSITORY} this week:\n\nšŸ” Total Clones: ${COUNT}\nšŸ‘¤ Unique Cloners: ${UNIQUES}\" }] }" \ No newline at end of file From e83201214e97c59a8c2786350c4e542f471af400 Mon Sep 17 00:00:00 2001 From: Dopeamin Date: Tue, 25 Mar 2025 09:18:54 +0100 Subject: [PATCH 32/32] removes on pr --- .github/workflows/weekly_clone_stats.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/weekly_clone_stats.yml b/.github/workflows/weekly_clone_stats.yml index 7d62be2..b56d03f 100644 --- a/.github/workflows/weekly_clone_stats.yml +++ b/.github/workflows/weekly_clone_stats.yml @@ -4,10 +4,6 @@ on: schedule: - cron: '0 8 * * 1' # Every Monday at 08:00 UTC - pull_request: - branches: - - main - permissions: contents: read