From b7baa0fba4a2bf2a74e968c84b86a21c9fe94454 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:20:44 +0400 Subject: [PATCH 01/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 11c42d5..c927094 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -41,7 +41,7 @@ jobs: - name: Get commits id: get_commits - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: # checkout full tree fetch-depth: 0 @@ -173,7 +173,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Update repository run: git pull From 044e3a1d493df3ecc2b990abe9ddcafba97af524 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:26:04 +0400 Subject: [PATCH 02/88] Create update_cars.yml --- .github/workflows/update_cars.yml | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/update_cars.yml diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml new file mode 100644 index 0000000..bf6b594 --- /dev/null +++ b/.github/workflows/update_cars.yml @@ -0,0 +1,83 @@ +name: Generate Astro Files from XML + +on: + # schedule: + # - cron: '0 */4 * * *' # Запускается каждые 4 часа + push: + paths: + - 'output.txt' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + # Указываете окружение и его переменные + environment: + name: ${{ github.ref == 'refs/heads/main' && 'production' || 'development' }} + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Set output + id: set_output + run: | + if [ -f output.txt ]; then + # Кодируем содержимое файла в base64 + encoded_output=$(base64 -w 0 output.txt) + # Передаем закодированное значение + echo "script_output=$encoded_output" >> $GITHUB_OUTPUT + fi + + - name: cat output + run: | + cat output.txt + + - name: Check for changes + id: check_changes + run: | + if git diff --exit-code; then + echo 'check_changes true — git diff' + echo "changes=true" >> $GITHUB_ENV + echo "changes=true" >> $GITHUB_OUTPUT + elif git status -s; then + echo 'check_changes true — git status' + echo "changes=true" >> $GITHUB_ENV + echo "changes=true" >> $GITHUB_OUTPUT + else + echo 'check_changes else' + echo "false — changes=false" >> $GITHUB_ENV + echo "changes=false" >> $GITHUB_OUTPUT + fi + continue-on-error: true + + - name: Commit files + if: env.changes == 'true' + run: | + git config --local user.email "support+actions@github.com" + git config --local user.name "github-actions-bot" + if [[ -d public/img/thumbs && $(find public/img/thumbs -type f -name "*.webp") ]]; then git add public/img/thumbs/*.webp; fi + if [[ -d src/content/cars && $(find src/content/cars -type f -name "*.mdx") ]]; then git add src/content/cars/*.mdx; fi + if [[ -f public/cars.xml ]]; then git add public/cars.xml; fi + git commit -m "Update cars from XML" -a || echo "No changes to commit" + git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git + git push origin $GITHUB_REF_NAME + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + outputs: + changes: ${{ steps.check_changes.outputs.changes }} + script_output: ${{ steps.set_output.outputs.script_output }} + + + notify_telegram: + needs: build + if: ${{ needs.build.outputs.script_output != '' }} + uses: ./.github/workflows/github-telegram.yml + with: + additional-text: | +
$(echo "${{ needs.build.outputs.script_output }}" | base64 -d)
+ secrets: + TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} + TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} From 5bc306116c934a34c09874cd8cc0dc688180968b Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:26:11 +0400 Subject: [PATCH 03/88] Create output.txt --- output.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 output.txt diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..1dff3a9 --- /dev/null +++ b/output.txt @@ -0,0 +1,2 @@ +Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Желтый' not found From cfb4b9537ca61692fbaa5886701097f780891539 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:31:49 +0400 Subject: [PATCH 04/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 1dff3a9..8c1190c 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found -Error: Model 'Emgrand, II' or Color 'Желтый' not found +Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Желтый' not found From 18cf479235d8d1f01cbc53e3ec82f82a72e6f049 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:32:42 +0400 Subject: [PATCH 05/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 8c1190c..4dbca74 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found -Error: Model 'Emgrand, II' or Color 'Желтый' not found +Error: Model 'Emgrand, II' or Color 'Серый' not found\n +Error: Model 'Emgrand, II' or Color 'Желтый' not found\n From 39b53a73fea04b1d3c31e1f711dd221fcbedc201 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:33:30 +0400 Subject: [PATCH 06/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 4dbca74..0d1ed0f 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\n -Error: Model 'Emgrand, II' or Color 'Желтый' not found\n +Error: Model 'Emgrand, II' or Color 'Серый' not found\n
+Error: Model 'Emgrand, II' or Color 'Желтый' not found\n
From 6537cbf777df429a3c208b94bb6e128ea27757df Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:35:41 +0400 Subject: [PATCH 07/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 0d1ed0f..217c463 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\n
-Error: Model 'Emgrand, II' or Color 'Желтый' not found\n
+Error: Model 'Emgrand, II' or Color 'Серый' not found\n +Error: Model 'Emgrand, II' or Color 'Желтый' not found\n From 5e07b5860737d6af0aca2fd7f80e967fd6fc6f38 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:36:27 +0400 Subject: [PATCH 08/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 217c463..8c19728 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\n -Error: Model 'Emgrand, II' or Color 'Желтый' not found\n +Error: Model 'Emgrand, II' or Color 'Серый' not found%0A +Error: Model 'Emgrand, II' or Color 'Желтый' not found%0A From 61fde3c8b571897a7a68c569fb7909494e4151a8 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:42:59 +0400 Subject: [PATCH 09/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index c927094..eb5462e 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -194,11 +194,8 @@ jobs: run: | additional_text="${{ inputs.additional-text || '' }}" if [ "$additional_text" != "" ]; then - echo "additional_text<> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo $additional_text >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + encoded_additional_text=$(echo "$additional_text" | base64 -w 0) + echo "additional_text=$encoded_additional_text" >> $GITHUB_OUTPUT fi - name: Send message to Telegram @@ -211,7 +208,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} - ${{ steps.set_outputs.outputs.additional_text }} + $(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d) ${{ steps.get_commits.outputs.message }} From c1fc8da98d0fe5832f012e56d33d7f15182c1fa2 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:43:24 +0400 Subject: [PATCH 10/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 8c19728..1dff3a9 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found%0A -Error: Model 'Emgrand, II' or Color 'Желтый' not found%0A +Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Желтый' not found From c9d632015531000bab8c2be08d7569d929ed09e4 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:47:35 +0400 Subject: [PATCH 11/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index eb5462e..9136f24 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -193,9 +193,13 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | additional_text="${{ inputs.additional-text || '' }}" + echo additional_text if [ "$additional_text" != "" ]; then - encoded_additional_text=$(echo "$additional_text" | base64 -w 0) - echo "additional_text=$encoded_additional_text" >> $GITHUB_OUTPUT + echo "additional_text<> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo $additional_text >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT fi - name: Send message to Telegram @@ -208,7 +212,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} - $(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d) + ${{ steps.set_outputs.outputs.additional_text }} ${{ steps.get_commits.outputs.message }} From 981efbc3677fe6c1f1335cb2cfd03c79cd76005f Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:48:05 +0400 Subject: [PATCH 12/88] Update output.txt --- output.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/output.txt b/output.txt index 1dff3a9..9ea0997 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,3 @@ Error: Model 'Emgrand, II' or Color 'Серый' not found + Error: Model 'Emgrand, II' or Color 'Желтый' not found From c481fd2d8ab4a4cf22a7044e17400e0240b37174 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:50:06 +0400 Subject: [PATCH 13/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 9136f24..54830c3 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -193,7 +193,7 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | additional_text="${{ inputs.additional-text || '' }}" - echo additional_text + echo $additional_text if [ "$additional_text" != "" ]; then echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT From 593ee2e5ee6a8fde1d5b6d9da4ee3b9c6c525566 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:51:09 +0400 Subject: [PATCH 14/88] Update output.txt --- output.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/output.txt b/output.txt index 9ea0997..0cec9a9 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1,4 @@ Error: Model 'Emgrand, II' or Color 'Серый' not found + Error: Model 'Emgrand, II' or Color 'Желтый' not found From b8d7e6055875f81dcc1794e08c4972b6cfd89d88 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:54:02 +0400 Subject: [PATCH 15/88] Update output.txt --- output.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/output.txt b/output.txt index 0cec9a9..d2d177d 100644 --- a/output.txt +++ b/output.txt @@ -1,4 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found - - -Error: Model 'Emgrand, II' or Color 'Желтый' not found +Error: Model 'Emgrand, II' or Color 'Серый' not found
+Error: Model 'Emgrand, II' or Color 'Желтый' not found
From 8ab53cee3b997932e6d163d47eede1b34af6d8de Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:58:30 +0400 Subject: [PATCH 16/88] test --- .github/workflows/github-telegram.yml | 10 +++------- .github/workflows/update_cars.yml | 2 +- output.txt | 5 +++-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 54830c3..0cda4ba 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -193,13 +193,9 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | additional_text="${{ inputs.additional-text || '' }}" - echo $additional_text if [ "$additional_text" != "" ]; then - echo "additional_text<> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo $additional_text >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + encoded_additional_text=$(echo "$additional_text" | base64 -w 0) + echo "additional_text=$additional_text" >> $GITHUB_OUTPUT fi - name: Send message to Telegram @@ -212,7 +208,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} - ${{ steps.set_outputs.outputs.additional_text }} +
$(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d | sed 's/$/
/')
${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index bf6b594..1d89474 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -77,7 +77,7 @@ jobs: uses: ./.github/workflows/github-telegram.yml with: additional-text: | -
$(echo "${{ needs.build.outputs.script_output }}" | base64 -d)
+ ${{ needs.build.outputs.script_output }} secrets: TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} diff --git a/output.txt b/output.txt index d2d177d..9ea0997 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,3 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found
-Error: Model 'Emgrand, II' or Color 'Желтый' not found
+Error: Model 'Emgrand, II' or Color 'Серый' not found + +Error: Model 'Emgrand, II' or Color 'Желтый' not found From 2b65e52c494de48d6ccfe46e8876486f5873a057 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 12:59:52 +0400 Subject: [PATCH 17/88] Update output.txt --- output.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/output.txt b/output.txt index 9ea0997..1dff3a9 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1,2 @@ Error: Model 'Emgrand, II' or Color 'Серый' not found - Error: Model 'Emgrand, II' or Color 'Желтый' not found From b7f979cc3647e924546cc094c658b6ec5648fdb0 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:00:56 +0400 Subject: [PATCH 18/88] Update output.txt --- output.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 1dff3a9..e1e5556 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found -Error: Model 'Emgrand, II' or Color 'Желтый' not found +Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file From 30a1c0c5d06b41380d61ff4b6c519967e0470019 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:02:41 +0400 Subject: [PATCH 19/88] t --- .github/workflows/github-telegram.yml | 2 +- output.txt | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 0cda4ba..0af3b83 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -208,7 +208,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
$(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d | sed 's/$/
/')
+
$(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d)
${{ steps.get_commits.outputs.message }} diff --git a/output.txt b/output.txt index e1e5556..28963b6 100644 --- a/output.txt +++ b/output.txt @@ -1 +1,2 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file From ee9bf34125dd15c36a65515edf6b101941807ba0 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:10:31 +0400 Subject: [PATCH 20/88] tt --- .github/workflows/github-telegram.yml | 12 ++++++++---- .github/workflows/update_cars.yml | 2 +- output.txt | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 0af3b83..12a845c 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -31,7 +31,7 @@ jobs: # This workflow contains a job called "build" adn "log-github-event-goodies" push: - if: ${{ github.event.commits != null }} + if: ${{ github.event.commits != null && inputs.additional-text == null }} # The type of runner that the job will run on runs-on: ubuntu-latest @@ -193,9 +193,13 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | additional_text="${{ inputs.additional-text || '' }}" + echo $additional_text if [ "$additional_text" != "" ]; then - encoded_additional_text=$(echo "$additional_text" | base64 -w 0) - echo "additional_text=$additional_text" >> $GITHUB_OUTPUT + echo "additional_text<> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo $additional_text >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT fi - name: Send message to Telegram @@ -208,7 +212,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
$(echo "${{ steps.set_outputs.outputs.additional_text }}" | base64 -d)
+ ${{ steps.set_outputs.outputs.additional_text }} ${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 1d89474..bf6b594 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -77,7 +77,7 @@ jobs: uses: ./.github/workflows/github-telegram.yml with: additional-text: | - ${{ needs.build.outputs.script_output }} +
$(echo "${{ needs.build.outputs.script_output }}" | base64 -d)
secrets: TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} diff --git a/output.txt b/output.txt index 28963b6..d03dccd 100644 --- a/output.txt +++ b/output.txt @@ -1,2 +1,3 @@ Error: Model 'Emgrand, II' or Color 'Серый' not found + Error: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file From 2c13a29eabfebf727dc73a348e42088d25b8afae Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:12:19 +0400 Subject: [PATCH 21/88] ttt --- .github/workflows/github-telegram.yml | 2 +- .github/workflows/update_cars.yml | 2 +- output.txt | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 12a845c..17ebb86 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -212,7 +212,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} - ${{ steps.set_outputs.outputs.additional_text }} +
${{ steps.set_outputs.outputs.additional_text }}
${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index bf6b594..2ea9b53 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -77,7 +77,7 @@ jobs: uses: ./.github/workflows/github-telegram.yml with: additional-text: | -
$(echo "${{ needs.build.outputs.script_output }}" | base64 -d)
+ $(echo "${{ needs.build.outputs.script_output }}" | base64 -d) secrets: TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} diff --git a/output.txt b/output.txt index d03dccd..482c095 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1,3 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found - -Error: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Желтый' not found\n +Error: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file From f11197592aa13a7e92adddaa0bcdb8d569525b65 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:23:24 +0400 Subject: [PATCH 22/88] tttt --- .github/workflows/github-telegram.yml | 4 +++- .github/workflows/update_cars.yml | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 17ebb86..d6874f9 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -193,7 +193,8 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | additional_text="${{ inputs.additional-text || '' }}" - echo $additional_text + echo additional_text: $additional_text + echo additional-text: ${{ inputs.additional-text || '' }} if [ "$additional_text" != "" ]; then echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT @@ -213,6 +214,7 @@ jobs: message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }}
${{ steps.set_outputs.outputs.additional_text }}
+
${{ inputs.additional-text || '' }}
${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 2ea9b53..913e550 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -5,6 +5,7 @@ on: # - cron: '0 */4 * * *' # Запускается каждые 4 часа push: paths: + - '.github/workflows/github-telegram.yml' - 'output.txt' workflow_dispatch: From c863639dd64f77b3cbb0da358affdd5e50c2b570 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:27:01 +0400 Subject: [PATCH 23/88] qq --- .github/workflows/github-telegram.yml | 6 ++++-- .github/workflows/update_cars.yml | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index d6874f9..be04e0e 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,9 +192,10 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - additional_text="${{ inputs.additional-text || '' }}" - echo additional_text: $additional_text echo additional-text: ${{ inputs.additional-text || '' }} + echo base64: $(echo "${{ inputs.additional-text }}" | base64 -d) + additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) + echo additional_text: $additional_text if [ "$additional_text" != "" ]; then echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT @@ -202,6 +203,7 @@ jobs: echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi + echo $GITHUB_OUTPUT - name: Send message to Telegram if: ${{ steps.get_commits.outputs.hash != '' }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 913e550..efaba29 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -78,7 +78,7 @@ jobs: uses: ./.github/workflows/github-telegram.yml with: additional-text: | - $(echo "${{ needs.build.outputs.script_output }}" | base64 -d) + ${{ needs.build.outputs.script_output }} secrets: TELEGRAM_TO: ${{ secrets.TELEGRAM_TO }} TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} From 1ee3d96fc417526fd51bb30ec4dcd2809bf6a114 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:33:39 +0400 Subject: [PATCH 24/88] ww --- .github/workflows/github-telegram.yml | 11 +++++++++++ .github/workflows/update_cars.yml | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index be04e0e..2e0683e 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,6 +192,13 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | + ex_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\n \ + \nError: Model 'Emgrand, II' or Color 'Желтый' not found" + if [ "$ex_text" != "" ]; then + encoded_ex_text=$(echo -e "$ex_text" | base64 -w 0) + echo "ex_text=$encoded_ex_text" >> $GITHUB_OUTPUT + fi + echo encoded_ex_text: encoded_ex_text echo additional-text: ${{ inputs.additional-text || '' }} echo base64: $(echo "${{ inputs.additional-text }}" | base64 -d) additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) @@ -205,6 +212,10 @@ jobs: fi echo $GITHUB_OUTPUT + if [ -f output.txt ]; then + echo encoded_output=$(base64 -w 0 output.txt) + fi + - name: Send message to Telegram if: ${{ steps.get_commits.outputs.hash != '' }} uses: appleboy/telegram-action@master diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index efaba29..6135886 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -25,10 +25,10 @@ jobs: id: set_output run: | if [ -f output.txt ]; then - # Кодируем содержимое файла в base64 - encoded_output=$(base64 -w 0 output.txt) - # Передаем закодированное значение - echo "script_output=$encoded_output" >> $GITHUB_OUTPUT + # Кодируем содержимое файла в base64 + encoded_output=$(base64 -w 0 output.txt) + # Передаем закодированное значение + echo "script_output=$encoded_output" >> $GITHUB_OUTPUT fi - name: cat output From c6ab87bb72c379585f072c6cc9b55b138b3c3d01 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:34:50 +0400 Subject: [PATCH 25/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 2e0683e..a11106d 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -198,7 +198,7 @@ jobs: encoded_ex_text=$(echo -e "$ex_text" | base64 -w 0) echo "ex_text=$encoded_ex_text" >> $GITHUB_OUTPUT fi - echo encoded_ex_text: encoded_ex_text + echo encoded_ex_text: $encoded_ex_text echo additional-text: ${{ inputs.additional-text || '' }} echo base64: $(echo "${{ inputs.additional-text }}" | base64 -d) additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) From 615e000e29c90dfbd095f327eccc3d69518ddd9f Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:37:15 +0400 Subject: [PATCH 26/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index a11106d..37806cc 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -212,8 +212,10 @@ jobs: fi echo $GITHUB_OUTPUT - if [ -f output.txt ]; then - echo encoded_output=$(base64 -w 0 output.txt) + if [ -f output.txt ]; then + echo "script_output=$(> $GITHUB_ENV + echo "script_output=$(> $GITHUB_OUTPUT fi - name: Send message to Telegram From a9bd484ef7f042c8563f5473640421376684ca13 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 13:41:55 +0400 Subject: [PATCH 27/88] qwe --- .github/workflows/github-telegram.yml | 5 ++--- .github/workflows/update_cars.yml | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 37806cc..4086869 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,8 +192,7 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - ex_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\n \ - \nError: Model 'Emgrand, II' or Color 'Желтый' not found" + ex_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\n\nError: Model 'Emgrand, II' or Color 'Желтый' not found" if [ "$ex_text" != "" ]; then encoded_ex_text=$(echo -e "$ex_text" | base64 -w 0) echo "ex_text=$encoded_ex_text" >> $GITHUB_OUTPUT @@ -214,7 +213,6 @@ jobs: if [ -f output.txt ]; then echo "script_output=$(> $GITHUB_ENV echo "script_output=$(> $GITHUB_OUTPUT fi @@ -230,6 +228,7 @@ jobs: [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }}
${{ steps.set_outputs.outputs.additional_text }}
${{ inputs.additional-text || '' }}
+
${{ steps.set_outputs.outputs.script_output }}
${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 6135886..c229436 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -25,10 +25,9 @@ jobs: id: set_output run: | if [ -f output.txt ]; then - # Кодируем содержимое файла в base64 - encoded_output=$(base64 -w 0 output.txt) - # Передаем закодированное значение - echo "script_output=$encoded_output" >> $GITHUB_OUTPUT + echo "script_output=$(> $GITHUB_ENV + echo "script_output=$(> $GITHUB_OUTPUT fi - name: cat output From 9780d624d5d1bf56aa8b6a94c5e3b53ba7e35cce Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:00:18 +0400 Subject: [PATCH 28/88] qwe --- .github/workflows/github-telegram.yml | 3 +++ .github/workflows/update_cars.yml | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 4086869..a147328 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -197,6 +197,7 @@ jobs: encoded_ex_text=$(echo -e "$ex_text" | base64 -w 0) echo "ex_text=$encoded_ex_text" >> $GITHUB_OUTPUT fi + echo ex_textе=$ex_text >> $GITHUB_OUTPUT echo encoded_ex_text: $encoded_ex_text echo additional-text: ${{ inputs.additional-text || '' }} echo base64: $(echo "${{ inputs.additional-text }}" | base64 -d) @@ -229,6 +230,8 @@ jobs:
${{ steps.set_outputs.outputs.additional_text }}
${{ inputs.additional-text || '' }}
${{ steps.set_outputs.outputs.script_output }}
+
${{ steps.set_outputs.outputs.ex_text }}
+
${{ steps.set_outputs.outputs.ex_textе }}
${{ steps.get_commits.outputs.message }} diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index c229436..6135886 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -25,9 +25,10 @@ jobs: id: set_output run: | if [ -f output.txt ]; then - echo "script_output=$(> $GITHUB_ENV - echo "script_output=$(> $GITHUB_OUTPUT + # Кодируем содержимое файла в base64 + encoded_output=$(base64 -w 0 output.txt) + # Передаем закодированное значение + echo "script_output=$encoded_output" >> $GITHUB_OUTPUT fi - name: cat output From dd825a44ec56955ac51ded172bccc4ba62b5b8bf Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:01:26 +0400 Subject: [PATCH 29/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index a147328..8b83a86 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -214,7 +214,7 @@ jobs: if [ -f output.txt ]; then echo "script_output=$(> $GITHUB_OUTPUT + echo "script_output=\"$(> $GITHUB_OUTPUT fi - name: Send message to Telegram @@ -231,7 +231,7 @@ jobs:
${{ inputs.additional-text || '' }}
${{ steps.set_outputs.outputs.script_output }}
${{ steps.set_outputs.outputs.ex_text }}
-
${{ steps.set_outputs.outputs.ex_textе }}
+
${{ steps.set_outputs.outputs.ex_textt }}
${{ steps.get_commits.outputs.message }} From 3dac517f202853153ec5c5032e7893312c971002 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:03:16 +0400 Subject: [PATCH 30/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 8b83a86..2223f0c 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -210,12 +210,6 @@ jobs: echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi - echo $GITHUB_OUTPUT - - if [ -f output.txt ]; then - echo "script_output=$(> $GITHUB_OUTPUT - fi - name: Send message to Telegram if: ${{ steps.get_commits.outputs.hash != '' }} @@ -229,7 +223,6 @@ jobs: [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }}
${{ steps.set_outputs.outputs.additional_text }}
${{ inputs.additional-text || '' }}
-
${{ steps.set_outputs.outputs.script_output }}
${{ steps.set_outputs.outputs.ex_text }}
${{ steps.set_outputs.outputs.ex_textt }}
${{ steps.get_commits.outputs.message }} From 13b4f33b10fcde9d71f50964c3bd49f5d9e40d21 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:08:30 +0400 Subject: [PATCH 31/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 2223f0c..59a1ae2 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,21 +192,13 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - ex_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\n\nError: Model 'Emgrand, II' or Color 'Желтый' not found" - if [ "$ex_text" != "" ]; then - encoded_ex_text=$(echo -e "$ex_text" | base64 -w 0) - echo "ex_text=$encoded_ex_text" >> $GITHUB_OUTPUT - fi - echo ex_textе=$ex_text >> $GITHUB_OUTPUT - echo encoded_ex_text: $encoded_ex_text - echo additional-text: ${{ inputs.additional-text || '' }} - echo base64: $(echo "${{ inputs.additional-text }}" | base64 -d) additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) echo additional_text: $additional_text if [ "$additional_text" != "" ]; then - echo "additional_text<> $GITHUB_OUTPUT + formatted_text=$(echo -e "$additional_text" | sed ':a;N;$!ba;s/\\n/\n/g') + echo "formatted_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo $additional_text >> $GITHUB_OUTPUT + echo $formatted_text >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi @@ -221,10 +213,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
${{ steps.set_outputs.outputs.additional_text }}
-
${{ inputs.additional-text || '' }}
-
${{ steps.set_outputs.outputs.ex_text }}
-
${{ steps.set_outputs.outputs.ex_textt }}
+
${{ steps.set_outputs.outputs.formatted_text }}
${{ steps.get_commits.outputs.message }} From 6cd26f3a9b3bc742e707c7057e07846447ef0320 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:13:41 +0400 Subject: [PATCH 32/88] Update output.txt --- output.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output.txt b/output.txt index 482c095..3d9c6a4 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1,3 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found +Error: Model 'Emgrand, II' or Color 'Серый' not found\n Error: Model 'Emgrand, II' or Color 'Желтый' not found\n -Error: Model 'Emgrand, II' or Color 'Желтый' not found \ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Желтый' not found\n \ No newline at end of file From 62cf41eebb2b540ceac87a96f184db20cc963319 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:15:23 +0400 Subject: [PATCH 33/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 59a1ae2..7dc3be3 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -213,7 +213,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
${{ steps.set_outputs.outputs.formatted_text }}
+ ${{ steps.set_outputs.outputs.formatted_text }} ${{ steps.get_commits.outputs.message }} From ca4da9f5d2c1a00a744141f047b7d1207a7d53dc Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 14:15:42 +0400 Subject: [PATCH 34/88] Update output.txt --- output.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/output.txt b/output.txt index 3d9c6a4..2eb3ae6 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1,3 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\n -Error: Model 'Emgrand, II' or Color 'Желтый' not found\n -Error: Model 'Emgrand, II' or Color 'Желтый' not found\n \ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Серый' not found
+Error: Model 'Emgrand, II' or Color 'Желтый' not found
+Error: Model 'Emgrand, II' or Color 'Желтый' not found
\ No newline at end of file From b91e2e64e81bb41fa3a065cc0ff1c9feecc65792 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:19:55 +0400 Subject: [PATCH 35/88] Update output.txt --- output.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/output.txt b/output.txt index 2eb3ae6..fdedabc 100644 --- a/output.txt +++ b/output.txt @@ -1,3 +1 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found
-Error: Model 'Emgrand, II' or Color 'Желтый' not found
-Error: Model 'Emgrand, II' or Color 'Желтый' not found
\ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Серый' not found\\nError: Model 'Emgrand, II' or Color 'Желтый' not found\\nError: Model 'Emgrand, II' or Color 'Желтый' not found\\n \ No newline at end of file From 9714e045ef14568dc74b17068adc59d602d78bc0 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:23:01 +0400 Subject: [PATCH 36/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 7dc3be3..d106aa4 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -195,7 +195,8 @@ jobs: additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) echo additional_text: $additional_text if [ "$additional_text" != "" ]; then - formatted_text=$(echo -e "$additional_text" | sed ':a;N;$!ba;s/\\n/\n/g') + formatted_text=$(echo "$additional_text" | sed 's/\\n/\ + /g') echo "formatted_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo $formatted_text >> $GITHUB_OUTPUT From 9e04f0d22b8c1d40969a34d3187a621305bca5f6 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:25:30 +0400 Subject: [PATCH 37/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index d106aa4..c81efbf 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -195,8 +195,10 @@ jobs: additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) echo additional_text: $additional_text if [ "$additional_text" != "" ]; then - formatted_text=$(echo "$additional_text" | sed 's/\\n/\ - /g') + # Разбиваем строку на массив по символу \n + IFS=$'\n' read -r -d '' -a lines <<< "$additional_text" + # Объединяем массив строк в одну строку с реальными переносами + formatted_text=$(printf "%s\n" "${lines[@]}") echo "formatted_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo $formatted_text >> $GITHUB_OUTPUT @@ -214,7 +216,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} - ${{ steps.set_outputs.outputs.formatted_text }} +
${{ steps.set_outputs.outputs.formatted_text }}
${{ steps.get_commits.outputs.message }} From 8b8c325e41541002a3b3b8ba80c4214b94df8599 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:27:25 +0400 Subject: [PATCH 38/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index c81efbf..c152c3b 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -198,10 +198,10 @@ jobs: # Разбиваем строку на массив по символу \n IFS=$'\n' read -r -d '' -a lines <<< "$additional_text" # Объединяем массив строк в одну строку с реальными переносами - formatted_text=$(printf "%s\n" "${lines[@]}") + # formatted_text=$(printf "%s\n" "${lines[@]}") echo "formatted_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo $formatted_text >> $GITHUB_OUTPUT + echo $(printf "%s\n" "${lines[@]}") >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi From 24bcbb86539eb716f16f1989283b08ef622a7efb Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:30:28 +0400 Subject: [PATCH 39/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index c152c3b..792a08b 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -195,14 +195,28 @@ jobs: additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) echo additional_text: $additional_text if [ "$additional_text" != "" ]; then + # Debug: print the original text + echo "Original additional_text:" + echo "$additional_text" + # Разбиваем строку на массив по символу \n - IFS=$'\n' read -r -d '' -a lines <<< "$additional_text" + IFS=$'\n' read -r -a lines <<< "$additional_text" + + # Debug: print the array + echo "Array elements:" + for line in "${lines[@]}"; do + echo "$line" + done + # Объединяем массив строк в одну строку с реальными переносами - # formatted_text=$(printf "%s\n" "${lines[@]}") + formatted_text=$(printf "%s\n" "${lines[@]}") + + # Debug: print the formatted text + echo "Formatted additional_text:" + echo "$formatted_text" + echo "formatted_text<> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo $(printf "%s\n" "${lines[@]}") >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT + echo "$formatted_text" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi From dbd47eb9b6eb8ccb0bdfc422f832ade999f5451a Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:32:04 +0400 Subject: [PATCH 40/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 792a08b..0414040 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,7 +192,8 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) + # additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) + additional_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found" echo additional_text: $additional_text if [ "$additional_text" != "" ]; then # Debug: print the original text From 1a2584e06fac8cf5776513ed6ef327e8b9558c3c Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:34:05 +0400 Subject: [PATCH 41/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 0414040..1da3de2 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -193,7 +193,7 @@ jobs: # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | # additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) - additional_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found" + additional_text="asd\nzxc\nqwe" echo additional_text: $additional_text if [ "$additional_text" != "" ]; then # Debug: print the original text From 9c0222585d148dcbb3a6be676e4984ea54fda256 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:36:31 +0400 Subject: [PATCH 42/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 1da3de2..919bd36 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,9 +192,7 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - # additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) - additional_text="asd\nzxc\nqwe" - echo additional_text: $additional_text + additional_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found" if [ "$additional_text" != "" ]; then # Debug: print the original text echo "Original additional_text:" From 222c9149b915c5a8bbed1d9d94de845d6238eac4 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:37:59 +0400 Subject: [PATCH 43/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 919bd36..c77534c 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -196,10 +196,10 @@ jobs: if [ "$additional_text" != "" ]; then # Debug: print the original text echo "Original additional_text:" - echo "$additional_text" + echo -e "$additional_text" # use echo -e to interpret \n # Разбиваем строку на массив по символу \n - IFS=$'\n' read -r -a lines <<< "$additional_text" + IFS=$'\n' read -r -d '' -a lines <<< "$(echo -e "$additional_text")" # Debug: print the array echo "Array elements:" From 591f849d31181906df4251ee9ac8eef75d09b27f Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:40:47 +0400 Subject: [PATCH 44/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index c77534c..4e76534 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -194,21 +194,8 @@ jobs: run: | additional_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found" if [ "$additional_text" != "" ]; then - # Debug: print the original text - echo "Original additional_text:" - echo -e "$additional_text" # use echo -e to interpret \n - - # Разбиваем строку на массив по символу \n - IFS=$'\n' read -r -d '' -a lines <<< "$(echo -e "$additional_text")" - - # Debug: print the array - echo "Array elements:" - for line in "${lines[@]}"; do - echo "$line" - done - - # Объединяем массив строк в одну строку с реальными переносами - formatted_text=$(printf "%s\n" "${lines[@]}") + # Форматируем текст с переносами строк + formatted_text=$(echo -e "$additional_text") # Debug: print the formatted text echo "Formatted additional_text:" From b0028a4f85121cfab9acae667b03f233fdadfc76 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:43:08 +0400 Subject: [PATCH 45/88] asd --- .github/workflows/github-telegram.yml | 2 +- output.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 4e76534..9cb12a2 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,7 +192,7 @@ jobs: id: set_outputs # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters run: | - additional_text="Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found" + additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) if [ "$additional_text" != "" ]; then # Форматируем текст с переносами строк formatted_text=$(echo -e "$additional_text") diff --git a/output.txt b/output.txt index fdedabc..91f74ea 100644 --- a/output.txt +++ b/output.txt @@ -1 +1 @@ -Error: Model 'Emgrand, II' or Color 'Серый' not found\\nError: Model 'Emgrand, II' or Color 'Желтый' not found\\nError: Model 'Emgrand, II' or Color 'Желтый' not found\\n \ No newline at end of file +Error: Model 'Emgrand, II' or Color 'Серый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\nError: Model 'Emgrand, II' or Color 'Желтый' not found\n \ No newline at end of file From 016001f5c956a1f586a9260fc602c80ff4415f07 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:48:11 +0400 Subject: [PATCH 46/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 9cb12a2..88f1697 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -195,14 +195,16 @@ jobs: additional_text=$(echo "${{ inputs.additional-text }}" | base64 -d) if [ "$additional_text" != "" ]; then # Форматируем текст с переносами строк - formatted_text=$(echo -e "$additional_text") + additional_text=$(echo -e "$additional_text") # Debug: print the formatted text echo "Formatted additional_text:" - echo "$formatted_text" + echo "$additional_text" - echo "formatted_text<> $GITHUB_OUTPUT - echo "$formatted_text" >> $GITHUB_OUTPUT + echo "additional_text<> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT + echo "$additional_text" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi From 91d47a0fa23f72737016316661ed312488e82db5 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:48:56 +0400 Subject: [PATCH 47/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 88f1697..3788504 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -218,7 +218,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
${{ steps.set_outputs.outputs.formatted_text }}
+
${{ steps.set_outputs.outputs.additional_text }}
${{ steps.get_commits.outputs.message }} From b366f3c33bb52af0889ee64379a2be097934c7f1 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sun, 2 Jun 2024 15:50:19 +0400 Subject: [PATCH 48/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 3788504..384c693 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -203,7 +203,9 @@ jobs: echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT + echo "
" >> $GITHUB_OUTPUT
             echo "$additional_text" >> $GITHUB_OUTPUT
+            echo "
" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi @@ -218,7 +220,7 @@ jobs: format: html message: | [${{ github.event.repository.name }}:${{ github.ref_name }}] Last commit by ${{ steps.get_commits.outputs.author }} -
${{ steps.set_outputs.outputs.additional_text }}
+ ${{ steps.set_outputs.outputs.additional_text }} ${{ steps.get_commits.outputs.message }} From 6133442c6b63c6e07851a1b8d1bed044f2d85d67 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Wed, 5 Jun 2024 11:18:55 +0500 Subject: [PATCH 49/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 384c693..67c5a78 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -203,9 +203,9 @@ jobs: echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo "
" >> $GITHUB_OUTPUT
+            echo "
" >> $GITHUB_OUTPUT echo "$additional_text" >> $GITHUB_OUTPUT - echo "
" >> $GITHUB_OUTPUT + echo "" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi From 5f6da4f9df20be0cb95ab3a090f1f0f698e47523 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Wed, 5 Jun 2024 11:28:53 +0500 Subject: [PATCH 50/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 67c5a78..7e1cc12 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -203,9 +203,8 @@ jobs: echo "additional_text<> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT - echo "
" >> $GITHUB_OUTPUT - echo "$additional_text" >> $GITHUB_OUTPUT - echo "
" >> $GITHUB_OUTPUT + echo "
$additional_text" >> $GITHUB_OUTPUT
+            echo "
" >> $GITHUB_OUTPUT echo "" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi From 3f243d6f9cc26587325a695d488a7bdd555e0903 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 11 Oct 2024 12:32:57 +0400 Subject: [PATCH 51/88] Update index.html --- index.html | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index f3d662a..924bb6d 100644 --- a/index.html +++ b/index.html @@ -2,9 +2,10 @@

Hello World

-

I'm hosted with GitHub Pages.

+

ссылка

1

2

3

+

ссылка

- \ No newline at end of file + From 0d10e896441dd9681cc1b7dae0ff84c08484148a Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:16 +0700 Subject: [PATCH 52/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 101 ++++++++++++++++---------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 7e1cc12..ac26d40 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -49,57 +49,82 @@ jobs: - name: Work with commits id: with_commits run: | + # Подготовка заголовка + HEADER="[${{ github.event.repository.name }}:${{ github.ref_name }}]" + if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then git fetch origin HEAD git checkout HEAD - mapfile -t COMMITS_ARRAY < <(git log --pretty=format:"'%h' - %an, %ar : %s" HEAD..${{ github.sha }}) + readarray=() + while IFS= read -r line; do + readarray+=("$line") + done < <(git log --pretty=format:"'%h' - %an, %ar : %s" HEAD..${{ github.sha }}) echo "before=${{ github.sha }}" >> $GITHUB_OUTPUT else - mapfile -t COMMITS_ARRAY < <(git log --pretty=format:"'%h' - %an, %ar : %s" ${{ github.event.before }}..${{ github.sha }}) + readarray=() + while IFS= read -r line; do + readarray+=("$line") + done < <(git log --pretty=format:"'%h' - %an, %ar : %s" ${{ github.event.before }}..${{ github.sha }}) echo "before=${{ github.event.before }}..${{ github.sha }}" >> $GITHUB_OUTPUT fi - # Process each commit - echo "full_list<> $GITHUB_OUTPUT - for COMMIT in "${COMMITS_ARRAY[@]}"; do - echo "$COMMIT" >> $GITHUB_OUTPUT - done - echo "EOF" >> $GITHUB_OUTPUT - - LINES_COUNT=${#COMMITS_ARRAY[*]} - if [ "$LINES_COUNT" == "1" ]; then - echo "lines_count=$LINES_COUNT new commit" >> $GITHUB_OUTPUT + COMMITS_ARRAY=("${readarray[@]}") + TOTAL_COMMITS=${#COMMITS_ARRAY[@]} + + if [ "$TOTAL_COMMITS" = "1" ]; then + COMMITS_TEXT="$TOTAL_COMMITS new commit" else - echo "lines_count=$LINES_COUNT new commits" >> $GITHUB_OUTPUT + COMMITS_TEXT="$TOTAL_COMMITS new commits" fi + HEADER="$HEADER $COMMITS_TEXT by ${{ github.actor }}" - - name: Set outputs - id: set_outputs - # The part of this solution to focus on is that we’re substituting the %, \n, and \r characters - run: | - additional_text="${{ inputs.additional-text || '' }}" - if [ "$additional_text" != "" ]; then - echo "additional_text<> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo $additional_text >> $GITHUB_OUTPUT - echo "" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + # Разбиваем коммиты на части по 40 штук + PARTS=() + CHUNK="" + COUNT=0 + MAX_COMMITS=40 + + for COMMIT in "${COMMITS_ARRAY[@]}"; do + if [ $COUNT -eq 0 ]; then + CHUNK="$HEADER\n\n" + fi + CHUNK+="$COMMIT\n" + COUNT=$((COUNT + 1)) + + if [ $COUNT -eq $MAX_COMMITS ]; then + PARTS+=("$CHUNK") + COUNT=0 + fi + done + + # Добавляем оставшиеся коммиты, если есть + if [ $COUNT -gt 0 ]; then + PARTS+=("$CHUNK") fi - - name: Send message to Telegram - if: ${{ steps.with_commits.outputs.full_list != '' }} - uses: appleboy/telegram-action@master - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - disable_web_page_preview: true - format: html - message: | - [${{ github.event.repository.name }}:${{ github.ref_name }}] ${{ steps.with_commits.outputs.lines_count }} by ${{ github.actor }} - ${{ steps.set_outputs.outputs.additional_text }} - ${{ steps.with_commits.outputs.full_list }} + # Записываем части в выходные данные + for INDEX in "${!PARTS[@]}"; do + echo "part_$INDEX<> $GITHUB_OUTPUT + echo "${PARTS[$INDEX]}" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + done + echo "total_parts=${#PARTS[@]}" >> $GITHUB_OUTPUT + - name: Send messages to Telegram + if: ${{ steps.with_commits.outputs.total_parts != '' }} + run: | + for i in $(seq 0 $((${{ steps.with_commits.outputs.total_parts }} - 1))); do + # Используем format для создания имени переменной + PART_NAME="part_${i}" + MESSAGE=$(echo "${{ steps.with_commits.outputs }}" | grep "^${PART_NAME}<> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT fi - + - name: Send message to Telegram if: ${{ steps.get_commits.outputs.hash != '' }} uses: appleboy/telegram-action@master From c062b8944017af4f3c905616dc656c653e20cbee Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:24 +0700 Subject: [PATCH 53/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index f3d662a..2445769 100644 --- a/index.html +++ b/index.html @@ -6,5 +6,6 @@

Hello World

1

2

3

+

3

\ No newline at end of file From d2b831eca23a8ea1c7fa0c1d3d5b7d8f42fdc872 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:27 +0700 Subject: [PATCH 54/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 2445769..a3a6bc4 100644 --- a/index.html +++ b/index.html @@ -7,5 +7,6 @@

Hello World

2

3

3

+

3

\ No newline at end of file From c050310eaff4f8d608a322e57fa45036a097c4d6 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:34 +0700 Subject: [PATCH 55/88] asdasdasdasd --- index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.html b/index.html index a3a6bc4..f3d662a 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,5 @@

Hello World

1

2

3

-

3

-

3

\ No newline at end of file From 46991d6ae77360fe560de52bf12622a0e7a9fe97 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:37 +0700 Subject: [PATCH 56/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index f3d662a..2445769 100644 --- a/index.html +++ b/index.html @@ -6,5 +6,6 @@

Hello World

1

2

3

+

3

\ No newline at end of file From 0400e1ac490a8d41e02d66f1a1b000089f72448c Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:03:40 +0700 Subject: [PATCH 57/88] Update index.html --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index 2445769..f3d662a 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,5 @@

Hello World

1

2

3

-

3

\ No newline at end of file From e98139a6384ff0fe4327687186c4ce1bbf8fe356 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:05:31 +0700 Subject: [PATCH 58/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 924bb6d..b27f686 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@

Hello World

1

2

3

+

3

ссылка

From 5034fca1764ead082000c99c7455397341661e0b Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:05:35 +0700 Subject: [PATCH 59/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index b27f686..9876a7f 100644 --- a/index.html +++ b/index.html @@ -7,6 +7,7 @@

Hello World

2

3

3

+

3

ссылка

From 776e480f91f9af6b62fb76b27893dbda86872ff7 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:05:39 +0700 Subject: [PATCH 60/88] Update index.html --- index.html | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.html b/index.html index 9876a7f..924bb6d 100644 --- a/index.html +++ b/index.html @@ -6,8 +6,6 @@

Hello World

1

2

3

-

3

-

3

ссылка

From 65a3384e64f08e696817a26336c4d32c1293155d Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:08:11 +0700 Subject: [PATCH 61/88] Update update_cars.yml --- .github/workflows/update_cars.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 6135886..888ddc7 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -5,8 +5,8 @@ on: # - cron: '0 */4 * * *' # Запускается каждые 4 часа push: paths: - - '.github/workflows/github-telegram.yml' - - 'output.txt' + # - '.github/workflows/github-telegram.yml' + # - 'output.txt' workflow_dispatch: jobs: From f6d3a7b15f0d0e8e88b9fc2a56f3bc7a4fe5091c Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:08:15 +0700 Subject: [PATCH 62/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index ac26d40..f1ac870 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -110,6 +110,7 @@ jobs: echo "EOF" >> $GITHUB_OUTPUT done echo "total_parts=${#PARTS[@]}" >> $GITHUB_OUTPUT + echo $GITHUB_OUTPUT - name: Send messages to Telegram if: ${{ steps.with_commits.outputs.total_parts != '' }} @@ -119,6 +120,7 @@ jobs: PART_NAME="part_${i}" MESSAGE=$(echo "${{ steps.with_commits.outputs }}" | grep "^${PART_NAME}< Date: Fri, 29 Nov 2024 13:10:45 +0700 Subject: [PATCH 63/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index f1ac870..bc27b1b 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -115,13 +115,29 @@ jobs: - name: Send messages to Telegram if: ${{ steps.with_commits.outputs.total_parts != '' }} run: | + # Выведем все outputs для отладки + echo "All outputs:" + echo "${{ steps.with_commits.outputs }}" + echo "---" + for i in $(seq 0 $((${{ steps.with_commits.outputs.total_parts }} - 1))); do - # Используем format для создания имени переменной PART_NAME="part_${i}" - MESSAGE=$(echo "${{ steps.with_commits.outputs }}" | grep "^${PART_NAME}< Date: Fri, 29 Nov 2024 13:11:54 +0700 Subject: [PATCH 64/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 31 +++++---------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index bc27b1b..6ba5228 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -105,42 +105,21 @@ jobs: # Записываем части в выходные данные for INDEX in "${!PARTS[@]}"; do - echo "part_$INDEX<> $GITHUB_OUTPUT - echo "${PARTS[$INDEX]}" >> $GITHUB_OUTPUT - echo "EOF" >> $GITHUB_OUTPUT + # Сохраняем каждую часть как отдельный output без EOF маркеров + echo "message_${INDEX}=${PARTS[$INDEX]}" >> $GITHUB_OUTPUT done echo "total_parts=${#PARTS[@]}" >> $GITHUB_OUTPUT - echo $GITHUB_OUTPUT - name: Send messages to Telegram if: ${{ steps.with_commits.outputs.total_parts != '' }} run: | - # Выведем все outputs для отладки - echo "All outputs:" - echo "${{ steps.with_commits.outputs }}" - echo "---" - for i in $(seq 0 $((${{ steps.with_commits.outputs.total_parts }} - 1))); do - PART_NAME="part_${i}" - echo "Looking for part: $PART_NAME" - - # Сохраним весь вывод grep в переменную и выведем его - GREP_OUTPUT=$(echo "${{ steps.with_commits.outputs }}" | grep -A2 "^${PART_NAME}< Date: Fri, 29 Nov 2024 13:13:36 +0700 Subject: [PATCH 65/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 6ba5228..eaec8e0 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -103,10 +103,12 @@ jobs: PARTS+=("$CHUNK") fi - # Записываем части в выходные данные + # Создаем временную директорию для сообщений + mkdir -p ./tmp_messages + + # Записываем части в отдельные файлы for INDEX in "${!PARTS[@]}"; do - # Сохраняем каждую часть как отдельный output без EOF маркеров - echo "message_${INDEX}=${PARTS[$INDEX]}" >> $GITHUB_OUTPUT + echo "${PARTS[$INDEX]}" > "./tmp_messages/part_${INDEX}.txt" done echo "total_parts=${#PARTS[@]}" >> $GITHUB_OUTPUT @@ -114,12 +116,12 @@ jobs: if: ${{ steps.with_commits.outputs.total_parts != '' }} run: | for i in $(seq 0 $((${{ steps.with_commits.outputs.total_parts }} - 1))); do - MESSAGE_VAR="message_${i}" + MESSAGE=$(cat "./tmp_messages/part_${i}.txt" | tr '\n' ' ') echo "Sending part $i to Telegram" curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \ -d chat_id="${{ secrets.TELEGRAM_TO }}" \ -d parse_mode="HTML" \ - -d text="${{ steps.with_commits.outputs[format('{0}', MESSAGE_VAR)] }}" \ + -d text="$MESSAGE" \ -d disable_web_page_preview="true" done From 8ee29585dec1808e4a0bf3ae706c79a508de30fc Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:14:25 +0700 Subject: [PATCH 66/88] Update update_cars.yml --- .github/workflows/update_cars.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/update_cars.yml b/.github/workflows/update_cars.yml index 888ddc7..647b3c3 100644 --- a/.github/workflows/update_cars.yml +++ b/.github/workflows/update_cars.yml @@ -3,8 +3,8 @@ name: Generate Astro Files from XML on: # schedule: # - cron: '0 */4 * * *' # Запускается каждые 4 часа - push: - paths: + # push: + # paths: # - '.github/workflows/github-telegram.yml' # - 'output.txt' workflow_dispatch: From 01af96efef9d3aeab94997b043eda20f39e7f15b Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:14:33 +0700 Subject: [PATCH 67/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 924bb6d..b27f686 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@

Hello World

1

2

3

+

3

ссылка

From a8c8704f7a88a2cd2a6e994099cd8419db85b7ff Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:14:38 +0700 Subject: [PATCH 68/88] Update index.html --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index b27f686..924bb6d 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,6 @@

Hello World

1

2

3

-

3

ссылка

From 6555aa0fa2be5fe1fe05b188b44e15bdaa4266b3 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:16:37 +0700 Subject: [PATCH 69/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index eaec8e0..2375eb5 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -87,9 +87,9 @@ jobs: for COMMIT in "${COMMITS_ARRAY[@]}"; do if [ $COUNT -eq 0 ]; then - CHUNK="$HEADER\n\n" + CHUNK="$HEADER

" fi - CHUNK+="$COMMIT\n" + CHUNK+="$COMMIT
" COUNT=$((COUNT + 1)) if [ $COUNT -eq $MAX_COMMITS ]; then From fc230101a13a1269e871769fe86f409af25cc190 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:16:40 +0700 Subject: [PATCH 70/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 924bb6d..b27f686 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@

Hello World

1

2

3

+

3

ссылка

From ba305c394659cef2c7d2b5b54f923ecafdcd3a10 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Fri, 29 Nov 2024 13:16:47 +0700 Subject: [PATCH 71/88] asd --- index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/index.html b/index.html index b27f686..924bb6d 100644 --- a/index.html +++ b/index.html @@ -6,7 +6,6 @@

Hello World

1

2

3

-

3

ссылка

From 2df69d6011569815377fa39dd9f2116c233c8009 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 14 Dec 2024 18:05:24 +0700 Subject: [PATCH 72/88] Update index.html --- index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/index.html b/index.html index 924bb6d..b27f686 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,7 @@

Hello World

1

2

3

+

3

ссылка

From 4daced7858bc93829f02c0cc31d7fb95964a6640 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 19:48:48 +0700 Subject: [PATCH 73/88] move logic to sh --- .github/scripts/prepare_commits.sh | 73 +++++++++++++++++++++ .github/scripts/send_telegram.sh | 34 ++++++++++ .github/workflows/github-telegram.yml | 91 +++++---------------------- README.md | 12 ++++ package-lock.json | 6 ++ package.json | 12 ++++ 6 files changed, 154 insertions(+), 74 deletions(-) create mode 100755 .github/scripts/prepare_commits.sh create mode 100644 .github/scripts/send_telegram.sh create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/prepare_commits.sh new file mode 100755 index 0000000..bb34789 --- /dev/null +++ b/.github/scripts/prepare_commits.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# prepare_commits.sh + +prepare_commits() { + local repository_name="$1" + local ref_name="$2" + local before_sha="$3" + local after_sha="$4" + local actor="$5" + local repository="$6" + + # Проверка наличия всех параметров + if [ -z "$repository_name" ] || [ -z "$ref_name" ] || [ -z "$before_sha" ] || [ -z "$after_sha" ] || [ -z "$actor" ] || [ -z "$repository" ]; then + echo "Error: Missing required parameters" >&2 + echo "Usage: prepare_commits repository_name ref_name before_sha after_sha actor repository" >&2 + return 1 + fi + + # Подготовка заголовка + HEADER="[${repository_name}:${ref_name}]" + + if [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then + git fetch origin HEAD || { echo "Error: Failed to fetch git repository" >&2; return 1; } + git checkout HEAD || { echo "Error: Failed to checkout HEAD" >&2; return 1; } + + # Сохраняем вывод git log во временный массив + mapfile -t readarray < <(git log --pretty=format:"'%h' - %an, %ar : %s" "HEAD..${after_sha}") + COMPARE_HASH="${after_sha}" + else + # Сохраняем вывод git log во временный массив + mapfile -t readarray < <(git log --pretty=format:"'%h' - %an, %ar : %s" "${before_sha}..${after_sha}") + COMPARE_HASH="${before_sha}..${after_sha}" + fi + + TOTAL_COMMITS=${#readarray[@]} + + if [ "$TOTAL_COMMITS" -eq 1 ]; then + COMMITS_TEXT="$TOTAL_COMMITS new commit" + else + COMMITS_TEXT="$TOTAL_COMMITS new commits" + fi + + HEADER="$HEADER $COMMITS_TEXT by ${actor}" + + # Создаем временную директорию для сообщений + mkdir -p ./tmp_messages || { echo "Error: Failed to create tmp_messages directory" >&2; return 1; } + + # Разбиваем коммиты на части по 40 штук + PART_INDEX=0 + CHUNK="$HEADER

" + COUNT=0 + MAX_COMMITS=40 + + for COMMIT in "${readarray[@]}"; do + CHUNK+="$COMMIT
" + COUNT=$((COUNT + 1)) + + if [ $COUNT -eq $MAX_COMMITS ]; then + echo "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } + PART_INDEX=$((PART_INDEX + 1)) + COUNT=0 + CHUNK="$HEADER

" + fi + done + + # Добавляем оставшиеся коммиты, если есть + if [ $COUNT -gt 0 ]; then + echo "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } + PART_INDEX=$((PART_INDEX + 1)) + fi + + echo $PART_INDEX +} diff --git a/.github/scripts/send_telegram.sh b/.github/scripts/send_telegram.sh new file mode 100644 index 0000000..41e6efd --- /dev/null +++ b/.github/scripts/send_telegram.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# send_telegram.sh + +send_telegram_messages() { + local token="$1" + local chat_id="$2" + local total_parts="$3" + + if [ -z "$token" ] || [ -z "$chat_id" ] || [ -z "$total_parts" ]; then + echo "Error: Missing required parameters" >&2 + echo "Usage: send_telegram_messages token chat_id total_parts" >&2 + return 1 + fi + + for i in $(seq 0 $((total_parts - 1))); do + if [ ! -f "./tmp_messages/part_${i}.txt" ]; then + echo "Error: Message file part_${i}.txt not found" >&2 + continue + fi + + MESSAGE=$(tr '\n' ' ' < "./tmp_messages/part_${i}.txt") + echo "Sending part $i to Telegram" + + RESPONSE=$(curl -s -X POST "https://api.telegram.org/bot${token}/sendMessage" \ + -d "chat_id=${chat_id}" \ + -d "parse_mode=HTML" \ + -d "text=${MESSAGE}" \ + -d "disable_web_page_preview=true") + + if ! echo "$RESPONSE" | grep -q '"ok":true'; then + echo "Error sending message part $i: $RESPONSE" >&2 + fi + done +} \ No newline at end of file diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 2375eb5..818b13c 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -46,84 +46,27 @@ jobs: # checkout full tree fetch-depth: 0 - - name: Work with commits - id: with_commits + - name: Prepare commit messages + id: prepare run: | - # Подготовка заголовка - HEADER="[${{ github.event.repository.name }}:${{ github.ref_name }}]" - - if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then - git fetch origin HEAD - git checkout HEAD - readarray=() - while IFS= read -r line; do - readarray+=("$line") - done < <(git log --pretty=format:"'%h' - %an, %ar : %s" HEAD..${{ github.sha }}) - echo "before=${{ github.sha }}" >> $GITHUB_OUTPUT - else - readarray=() - while IFS= read -r line; do - readarray+=("$line") - done < <(git log --pretty=format:"'%h' - %an, %ar : %s" ${{ github.event.before }}..${{ github.sha }}) - echo "before=${{ github.event.before }}..${{ github.sha }}" >> $GITHUB_OUTPUT - fi - - COMMITS_ARRAY=("${readarray[@]}") - TOTAL_COMMITS=${#COMMITS_ARRAY[@]} - - if [ "$TOTAL_COMMITS" = "1" ]; then - COMMITS_TEXT="$TOTAL_COMMITS new commit" - else - COMMITS_TEXT="$TOTAL_COMMITS new commits" - fi - - HEADER="$HEADER $COMMITS_TEXT by ${{ github.actor }}" - - # Разбиваем коммиты на части по 40 штук - PARTS=() - CHUNK="" - COUNT=0 - MAX_COMMITS=40 - - for COMMIT in "${COMMITS_ARRAY[@]}"; do - if [ $COUNT -eq 0 ]; then - CHUNK="$HEADER

" - fi - CHUNK+="$COMMIT
" - COUNT=$((COUNT + 1)) - - if [ $COUNT -eq $MAX_COMMITS ]; then - PARTS+=("$CHUNK") - COUNT=0 - fi - done - - # Добавляем оставшиеся коммиты, если есть - if [ $COUNT -gt 0 ]; then - PARTS+=("$CHUNK") - fi - - # Создаем временную директорию для сообщений - mkdir -p ./tmp_messages - - # Записываем части в отдельные файлы - for INDEX in "${!PARTS[@]}"; do - echo "${PARTS[$INDEX]}" > "./tmp_messages/part_${INDEX}.txt" - done - echo "total_parts=${#PARTS[@]}" >> $GITHUB_OUTPUT + source ./scripts/prepare_commits.sh + total_parts=$(prepare_commits \ + "${{ github.event.repository.name }}" \ + "${{ github.ref_name }}" \ + "${{ github.event.before }}" \ + "${{ github.sha }}" \ + "${{ github.actor }}" \ + "${{ github.repository }}") + echo "total_parts=${total_parts}" >> $GITHUB_OUTPUT - name: Send messages to Telegram - if: ${{ steps.with_commits.outputs.total_parts != '' }} + if: ${{ steps.prepare.outputs.total_parts != '0' }} run: | - for i in $(seq 0 $((${{ steps.with_commits.outputs.total_parts }} - 1))); do - MESSAGE=$(cat "./tmp_messages/part_${i}.txt" | tr '\n' ' ') - echo "Sending part $i to Telegram" - curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \ - -d chat_id="${{ secrets.TELEGRAM_TO }}" \ - -d parse_mode="HTML" \ - -d text="$MESSAGE" \ - -d disable_web_page_preview="true" - done + source ./scripts/send_telegram.sh + send_telegram_messages \ + "${{ secrets.TELEGRAM_TOKEN }}" \ + "${{ secrets.TELEGRAM_TO }}" \ + "${{ steps.prepare.outputs.total_parts }}" create: diff --git a/README.md b/README.md index 13ab18b..2c134e4 100755 --- a/README.md +++ b/README.md @@ -4,3 +4,15 @@ test repo add -100 to channel id in Telegram + + +```bash +chmod +x ./.github/scripts/prepare_commits.sh +chmod +x ./.github/scripts/send_telegram.sh + +source ./.github/scripts/prepare_commits.sh +prepare_commits "repo-name" "main" "fc23010" "2df69d6" "username" "org/repo" + +source ./.github/scripts/prepare_commits.sh +prepare_commits "repo-name" "main" "2df69d6" "fc23010" "username" "org/repo" +``` diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e6ed465 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "alexsab.github.io", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..ec60bd8 --- /dev/null +++ b/package.json @@ -0,0 +1,12 @@ +{ + "name": "alexsab.github.io", + "version": "1.0.0", + "description": "[github pages](https://alexsab.github.io)", + "main": "index.js", + "scripts": { + "prepare_commits": ".github/scripts/prepare_commits.sh", + "send_telegram": ".github/scripts/send_telegram.sh" + }, + "author": "Alexsab.ru", + "license": "ISC" +} From fe81111fba48251689142d233217237adc0ef859 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 19:58:35 +0700 Subject: [PATCH 74/88] Update prepare_commits.sh --- .github/scripts/prepare_commits.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/prepare_commits.sh index bb34789..3a456dd 100755 --- a/.github/scripts/prepare_commits.sh +++ b/.github/scripts/prepare_commits.sh @@ -18,17 +18,24 @@ prepare_commits() { # Подготовка заголовка HEADER="[${repository_name}:${ref_name}]" + + # Инициализируем массив + declare -a readarray if [ "$before_sha" = "0000000000000000000000000000000000000000" ]; then git fetch origin HEAD || { echo "Error: Failed to fetch git repository" >&2; return 1; } git checkout HEAD || { echo "Error: Failed to checkout HEAD" >&2; return 1; } - # Сохраняем вывод git log во временный массив - mapfile -t readarray < <(git log --pretty=format:"'%h' - %an, %ar : %s" "HEAD..${after_sha}") + # Читаем вывод git log в массив + while IFS= read -r line; do + readarray+=("$line") + done < <(git log --pretty=format:"'%h' - %an, %ar : %s" "HEAD..${after_sha}") COMPARE_HASH="${after_sha}" else - # Сохраняем вывод git log во временный массив - mapfile -t readarray < <(git log --pretty=format:"'%h' - %an, %ar : %s" "${before_sha}..${after_sha}") + # Читаем вывод git log в массив + while IFS= read -r line; do + readarray+=("$line") + done < <(git log --pretty=format:"'%h' - %an, %ar : %s" "${before_sha}..${after_sha}") COMPARE_HASH="${before_sha}..${after_sha}" fi @@ -49,7 +56,7 @@ prepare_commits() { PART_INDEX=0 CHUNK="$HEADER

" COUNT=0 - MAX_COMMITS=40 + MAX_COMMITS=5 for COMMIT in "${readarray[@]}"; do CHUNK+="$COMMIT
" From d9068b17970f719f50735dd3d0dfaadd2bf535e5 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 21:47:51 +0700 Subject: [PATCH 75/88] fix use br in telegram --- .github/scripts/prepare_commits.sh | 10 +++++----- .github/scripts/send_telegram.sh | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/prepare_commits.sh index 3a456dd..4d6916e 100755 --- a/.github/scripts/prepare_commits.sh +++ b/.github/scripts/prepare_commits.sh @@ -54,25 +54,25 @@ prepare_commits() { # Разбиваем коммиты на части по 40 штук PART_INDEX=0 - CHUNK="$HEADER

" + CHUNK="$HEADER\n\n" COUNT=0 MAX_COMMITS=5 for COMMIT in "${readarray[@]}"; do - CHUNK+="$COMMIT
" + CHUNK+="$COMMIT\n" COUNT=$((COUNT + 1)) if [ $COUNT -eq $MAX_COMMITS ]; then - echo "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } + printf "%b" "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } PART_INDEX=$((PART_INDEX + 1)) COUNT=0 - CHUNK="$HEADER

" + CHUNK="$HEADER\n\n" fi done # Добавляем оставшиеся коммиты, если есть if [ $COUNT -gt 0 ]; then - echo "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } + printf "%b" "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } PART_INDEX=$((PART_INDEX + 1)) fi diff --git a/.github/scripts/send_telegram.sh b/.github/scripts/send_telegram.sh index 41e6efd..c22d47f 100644 --- a/.github/scripts/send_telegram.sh +++ b/.github/scripts/send_telegram.sh @@ -18,7 +18,7 @@ send_telegram_messages() { continue fi - MESSAGE=$(tr '\n' ' ' < "./tmp_messages/part_${i}.txt") + MESSAGE=$(cat "./tmp_messages/part_${i}.txt") echo "Sending part $i to Telegram" RESPONSE=$(curl -s -X POST "https://api.telegram.org/bot${token}/sendMessage" \ From 3067c8b0a1c784c581b8d4a31bf6baa50cc61213 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:15:16 +0700 Subject: [PATCH 76/88] use LENGTH for message --- .github/scripts/prepare_commits.sh | 50 +++++++++++++++++++++--------- .github/scripts/send_telegram.sh | 3 ++ 2 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/prepare_commits.sh index 4d6916e..6428568 100755 --- a/.github/scripts/prepare_commits.sh +++ b/.github/scripts/prepare_commits.sh @@ -16,8 +16,10 @@ prepare_commits() { return 1 fi - # Подготовка заголовка - HEADER="[${repository_name}:${ref_name}]" + # Максимальная длина сообщения в Telegram + local MAX_LENGTH=4096 + # Длина для эллипсиса и дополнительного пробела + local ELLIPSIS_LENGTH=4 # Инициализируем массив declare -a readarray @@ -47,31 +49,51 @@ prepare_commits() { COMMITS_TEXT="$TOTAL_COMMITS new commits" fi - HEADER="$HEADER $COMMITS_TEXT by ${actor}" + # Подготовка заголовка + HEADER="[${repository_name}:${ref_name}] $COMMITS_TEXT by ${actor}" # Создаем временную директорию для сообщений mkdir -p ./tmp_messages || { echo "Error: Failed to create tmp_messages directory" >&2; return 1; } - # Разбиваем коммиты на части по 40 штук + # Разбиваем сообщение на части по количеству символов PART_INDEX=0 CHUNK="$HEADER\n\n" - COUNT=0 - MAX_COMMITS=5 + CURRENT_LENGTH=${#CHUNK} + + # Максимальная длина для одного коммита (с учетом заголовка и отступов) + local MAX_COMMIT_LENGTH=$((MAX_LENGTH - ${#HEADER} - 2)) for COMMIT in "${readarray[@]}"; do - CHUNK+="$COMMIT\n" - COUNT=$((COUNT + 1)) - - if [ $COUNT -eq $MAX_COMMITS ]; then + # Добавляем перевод строки к коммиту + COMMIT_WITH_NEWLINE="$COMMIT\n" + COMMIT_LENGTH=${#COMMIT_WITH_NEWLINE} + + # Проверяем длину коммита + if [ $COMMIT_LENGTH -gt $MAX_COMMIT_LENGTH ]; then + echo "Warning: Commit message is too long and will be truncated" >&2 + # Обрезаем коммит с учетом места под эллипсис + COMMIT_WITH_NEWLINE="${COMMIT_WITH_NEWLINE:0:$((MAX_COMMIT_LENGTH - ELLIPSIS_LENGTH))} ...\n" + COMMIT_LENGTH=${#COMMIT_WITH_NEWLINE} + fi + + # Проверяем, поместится ли следующий коммит + if ((CURRENT_LENGTH + COMMIT_LENGTH > MAX_LENGTH)); then + # Сохраняем текущий чанк printf "%b" "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } PART_INDEX=$((PART_INDEX + 1)) - COUNT=0 - CHUNK="$HEADER\n\n" + + # Начинаем новый чанк с заголовка + CHUNK="$HEADER\n\n$COMMIT_WITH_NEWLINE" + CURRENT_LENGTH=$((${#HEADER} + 2 + COMMIT_LENGTH)) + else + # Добавляем коммит к текущему чанку + CHUNK+="$COMMIT_WITH_NEWLINE" + CURRENT_LENGTH=$((CURRENT_LENGTH + COMMIT_LENGTH)) fi done - # Добавляем оставшиеся коммиты, если есть - if [ $COUNT -gt 0 ]; then + # Сохраняем последний чанк, если он не пустой + if [ "$CHUNK" != "$HEADER\n\n" ]; then printf "%b" "$CHUNK" > "./tmp_messages/part_${PART_INDEX}.txt" || { echo "Error: Failed to write to file" >&2; return 1; } PART_INDEX=$((PART_INDEX + 1)) fi diff --git a/.github/scripts/send_telegram.sh b/.github/scripts/send_telegram.sh index c22d47f..d69f258 100644 --- a/.github/scripts/send_telegram.sh +++ b/.github/scripts/send_telegram.sh @@ -30,5 +30,8 @@ send_telegram_messages() { if ! echo "$RESPONSE" | grep -q '"ok":true'; then echo "Error sending message part $i: $RESPONSE" >&2 fi + + # Добавляем небольшую задержку между отправками сообщений + sleep 1 done } \ No newline at end of file From 6c634540c3d379af1b84ef3ccbff9063760e8241 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:18:18 +0700 Subject: [PATCH 77/88] add trim_quotes --- .github/scripts/prepare_commits.sh | 17 +++++++++++------ .github/scripts/send_telegram.sh | 11 ++++++++--- .github/scripts/utils.sh | 14 ++++++++++++++ 3 files changed, 33 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/utils.sh diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/prepare_commits.sh index 6428568..90285de 100755 --- a/.github/scripts/prepare_commits.sh +++ b/.github/scripts/prepare_commits.sh @@ -1,13 +1,18 @@ #!/bin/bash # prepare_commits.sh +# Подключаем утилиты +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/utils.sh" + prepare_commits() { - local repository_name="$1" - local ref_name="$2" - local before_sha="$3" - local after_sha="$4" - local actor="$5" - local repository="$6" + # Очищаем входные параметры от кавычек + local repository_name=$(trim_quotes "$1") + local ref_name=$(trim_quotes "$2") + local before_sha=$(trim_quotes "$3") + local after_sha=$(trim_quotes "$4") + local actor=$(trim_quotes "$5") + local repository=$(trim_quotes "$6") # Проверка наличия всех параметров if [ -z "$repository_name" ] || [ -z "$ref_name" ] || [ -z "$before_sha" ] || [ -z "$after_sha" ] || [ -z "$actor" ] || [ -z "$repository" ]; then diff --git a/.github/scripts/send_telegram.sh b/.github/scripts/send_telegram.sh index d69f258..7edeb27 100644 --- a/.github/scripts/send_telegram.sh +++ b/.github/scripts/send_telegram.sh @@ -1,10 +1,15 @@ #!/bin/bash # send_telegram.sh +# Подключаем утилиты +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +source "${SCRIPT_DIR}/utils.sh" + send_telegram_messages() { - local token="$1" - local chat_id="$2" - local total_parts="$3" + # Очищаем входные параметры от кавычек + local token=$(trim_quotes "$1") + local chat_id=$(trim_quotes "$2") + local total_parts=$(trim_quotes "$3") if [ -z "$token" ] || [ -z "$chat_id" ] || [ -z "$total_parts" ]; then echo "Error: Missing required parameters" >&2 diff --git a/.github/scripts/utils.sh b/.github/scripts/utils.sh new file mode 100644 index 0000000..26b4145 --- /dev/null +++ b/.github/scripts/utils.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# utils.sh + +# Функция для удаления кавычек из строки +trim_quotes() { + local string="$1" + # Удаляем двойные кавычки с начала и конца строки + string="${string#\"}" + string="${string%\"}" + # Удаляем одинарные кавычки с начала и конца строки + string="${string#\'}" + string="${string%\'}" + echo "$string" +} From 9eb514b627abbfe51ba526af1eab1104e8bd3a3b Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:18:31 +0700 Subject: [PATCH 78/88] Update README.md --- README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2c134e4..226d5b3 100755 --- a/README.md +++ b/README.md @@ -11,8 +11,17 @@ chmod +x ./.github/scripts/prepare_commits.sh chmod +x ./.github/scripts/send_telegram.sh source ./.github/scripts/prepare_commits.sh -prepare_commits "repo-name" "main" "fc23010" "2df69d6" "username" "org/repo" +prepare_commits "repo-name" "main" "13adf7b" "2df69d6" "username" "org/repo" source ./.github/scripts/prepare_commits.sh -prepare_commits "repo-name" "main" "2df69d6" "fc23010" "username" "org/repo" +prepare_commits "repo-name" "main" "91d47a0" "2df69d6" "username" "org/repo" + +if [ -z "$TELEGRAM_TOKEN" ] && [ -f .env ]; then + export TELEGRAM_TOKEN=$(grep '^TELEGRAM_TOKEN=' .env | awk -F'=' '{print substr($0, index($0,$2))}' | sed 's/^"//; s/"$//') +fi +if [ -z "$TELEGRAM_TO" ] && [ -f .env ]; then + export TELEGRAM_TO=$(grep '^TELEGRAM_TO=' .env | awk -F'=' '{print substr($0, index($0,$2))}' | sed 's/^"//; s/"$//') +fi +source ./.github/scripts/send_telegram.sh +send_telegram_messages $TELEGRAM_TOKEN $TELEGRAM_TO 2 ``` From b3c75b70c0f0d9507471ab9b00262e3780098f95 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:21:04 +0700 Subject: [PATCH 79/88] Update github-telegram.yml --- .github/workflows/github-telegram.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 818b13c..7c2e7a9 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -49,7 +49,7 @@ jobs: - name: Prepare commit messages id: prepare run: | - source ./scripts/prepare_commits.sh + source ./.github/scripts/prepare_commits.sh total_parts=$(prepare_commits \ "${{ github.event.repository.name }}" \ "${{ github.ref_name }}" \ @@ -62,7 +62,7 @@ jobs: - name: Send messages to Telegram if: ${{ steps.prepare.outputs.total_parts != '0' }} run: | - source ./scripts/send_telegram.sh + source ./.github/scripts/send_telegram.sh send_telegram_messages \ "${{ secrets.TELEGRAM_TOKEN }}" \ "${{ secrets.TELEGRAM_TO }}" \ From 36aeb085943a6ec3a265c65ba63d851cede17be2 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:21:07 +0700 Subject: [PATCH 80/88] Update package.json --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec60bd8..eee6890 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "[github pages](https://alexsab.github.io)", "main": "index.js", "scripts": { - "prepare_commits": ".github/scripts/prepare_commits.sh", - "send_telegram": ".github/scripts/send_telegram.sh" + "prepare_commits": "./.github/scripts/prepare_commits.sh", + "send_telegram": "./.github/scripts/send_telegram.sh" }, "author": "Alexsab.ru", "license": "ISC" From 5d14a269bb19de3b5eb4b7d5f52e94d98d454659 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:38:42 +0700 Subject: [PATCH 81/88] move script to sh --- .github/scripts/{ => sh}/prepare_commits.sh | 0 .github/scripts/{ => sh}/send_telegram.sh | 0 .github/scripts/{ => sh}/utils.sh | 0 .github/workflows/github-telegram.yml | 4 ++-- 4 files changed, 2 insertions(+), 2 deletions(-) rename .github/scripts/{ => sh}/prepare_commits.sh (100%) rename .github/scripts/{ => sh}/send_telegram.sh (100%) rename .github/scripts/{ => sh}/utils.sh (100%) diff --git a/.github/scripts/prepare_commits.sh b/.github/scripts/sh/prepare_commits.sh similarity index 100% rename from .github/scripts/prepare_commits.sh rename to .github/scripts/sh/prepare_commits.sh diff --git a/.github/scripts/send_telegram.sh b/.github/scripts/sh/send_telegram.sh similarity index 100% rename from .github/scripts/send_telegram.sh rename to .github/scripts/sh/send_telegram.sh diff --git a/.github/scripts/utils.sh b/.github/scripts/sh/utils.sh similarity index 100% rename from .github/scripts/utils.sh rename to .github/scripts/sh/utils.sh diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 7c2e7a9..16d5e6a 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -49,7 +49,7 @@ jobs: - name: Prepare commit messages id: prepare run: | - source ./.github/scripts/prepare_commits.sh + source ./.github/scripts/sh/prepare_commits.sh total_parts=$(prepare_commits \ "${{ github.event.repository.name }}" \ "${{ github.ref_name }}" \ @@ -62,7 +62,7 @@ jobs: - name: Send messages to Telegram if: ${{ steps.prepare.outputs.total_parts != '0' }} run: | - source ./.github/scripts/send_telegram.sh + source ./.github/scripts/sh/send_telegram.sh send_telegram_messages \ "${{ secrets.TELEGRAM_TOKEN }}" \ "${{ secrets.TELEGRAM_TO }}" \ From 1e8a4d29a012ed951e6e6ae6c1e04781a1c3bed5 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:47:25 +0700 Subject: [PATCH 82/88] add test.sh --- .github/scripts/sh/prepare_commits.sh | 4 --- .github/scripts/sh/send_telegram.sh | 4 --- .github/scripts/sh/test.sh | 52 +++++++++++++++++++++++++++ README.md | 14 +++++--- package.json | 4 +-- pnpm-lock.yaml | 5 +++ 6 files changed, 68 insertions(+), 15 deletions(-) create mode 100755 .github/scripts/sh/test.sh create mode 100644 pnpm-lock.yaml diff --git a/.github/scripts/sh/prepare_commits.sh b/.github/scripts/sh/prepare_commits.sh index 90285de..39e124d 100755 --- a/.github/scripts/sh/prepare_commits.sh +++ b/.github/scripts/sh/prepare_commits.sh @@ -1,10 +1,6 @@ #!/bin/bash # prepare_commits.sh -# Подключаем утилиты -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "${SCRIPT_DIR}/utils.sh" - prepare_commits() { # Очищаем входные параметры от кавычек local repository_name=$(trim_quotes "$1") diff --git a/.github/scripts/sh/send_telegram.sh b/.github/scripts/sh/send_telegram.sh index 7edeb27..ce1dbcd 100644 --- a/.github/scripts/sh/send_telegram.sh +++ b/.github/scripts/sh/send_telegram.sh @@ -1,10 +1,6 @@ #!/bin/bash # send_telegram.sh -# Подключаем утилиты -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "${SCRIPT_DIR}/utils.sh" - send_telegram_messages() { # Очищаем входные параметры от кавычек local token=$(trim_quotes "$1") diff --git a/.github/scripts/sh/test.sh b/.github/scripts/sh/test.sh new file mode 100755 index 0000000..3dce433 --- /dev/null +++ b/.github/scripts/sh/test.sh @@ -0,0 +1,52 @@ +# Функция для отображения справки +function show_help() { + echo "Usage: $0 [OPTIONS]" + echo + echo "Опции:" + echo " -p, --prepare_commits Подготовить коммиты для мержа." + echo " -s, --send_telegram Отправить сообщения в Telegram." + echo " -h, --help Показать эту справку." + echo + exit 0 +} + +# Переменные для флагов +prepare=false +send=false + +# Обрабатываем аргументы командной строки +for arg in "$@"; do + case $arg in + -h|--help) + show_help + ;; + -p|--prepare_commits) + prepare=true + ;; + -s|--send_telegram) + send=true + ;; + *) + echo "Неизвестный аргумент: $arg" + show_help + ;; + esac +done + +if $prepare; then + source ./.github/scripts/sh/utils.sh + source ./.github/scripts/sh/prepare_commits.sh + prepare_commits "repo-name" "main" "13adf7b" "2df69d6" "username" "org/repo" +fi + +if $send; then + if [ -z "$TELEGRAM_TOKEN" ] && [ -f .env ]; then + export TELEGRAM_TOKEN=$(grep '^TELEGRAM_TOKEN=' .env | awk -F'=' '{print substr($0, index($0,$2))}' | sed 's/^"//; s/"$//') + fi + if [ -z "$TELEGRAM_TO" ] && [ -f .env ]; then + export TELEGRAM_TO=$(grep '^TELEGRAM_TO=' .env | awk -F'=' '{print substr($0, index($0,$2))}' | sed 's/^"//; s/"$//') + fi + source ./.github/scripts/sh/utils.sh + source ./.github/scripts/sh/send_telegram.sh + send_telegram_messages $TELEGRAM_TOKEN $TELEGRAM_TO 2 +fi \ No newline at end of file diff --git a/README.md b/README.md index 226d5b3..7d0b89e 100755 --- a/README.md +++ b/README.md @@ -7,13 +7,16 @@ add -100 to channel id in Telegram ```bash -chmod +x ./.github/scripts/prepare_commits.sh -chmod +x ./.github/scripts/send_telegram.sh +chmod +x ./.github/scripts/sh/test.sh +chmod +x ./.github/scripts/sh/prepare_commits.sh +chmod +x ./.github/scripts/sh/send_telegram.sh -source ./.github/scripts/prepare_commits.sh +source ./.github/scripts/sh/utils.sh +source ./.github/scripts/sh/prepare_commits.sh prepare_commits "repo-name" "main" "13adf7b" "2df69d6" "username" "org/repo" -source ./.github/scripts/prepare_commits.sh +source ./.github/scripts/sh/utils.sh +source ./.github/scripts/sh/prepare_commits.sh prepare_commits "repo-name" "main" "91d47a0" "2df69d6" "username" "org/repo" if [ -z "$TELEGRAM_TOKEN" ] && [ -f .env ]; then @@ -22,6 +25,7 @@ fi if [ -z "$TELEGRAM_TO" ] && [ -f .env ]; then export TELEGRAM_TO=$(grep '^TELEGRAM_TO=' .env | awk -F'=' '{print substr($0, index($0,$2))}' | sed 's/^"//; s/"$//') fi -source ./.github/scripts/send_telegram.sh +source ./.github/scripts/sh/utils.sh +source ./.github/scripts/sh/send_telegram.sh send_telegram_messages $TELEGRAM_TOKEN $TELEGRAM_TO 2 ``` diff --git a/package.json b/package.json index eee6890..ac6aa44 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "[github pages](https://alexsab.github.io)", "main": "index.js", "scripts": { - "prepare_commits": "./.github/scripts/prepare_commits.sh", - "send_telegram": "./.github/scripts/send_telegram.sh" + "prepare_commits": "./.github/scripts/sh/test.sh --prepare_commits", + "send_telegram": "./.github/scripts/sh/test.sh --send_telegram" }, "author": "Alexsab.ru", "license": "ISC" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..2b9f188 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,5 @@ +lockfileVersion: '6.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false From d7a51579ef76f3d89e3bdde516e2da4bf0bb6b3f Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 22:48:39 +0700 Subject: [PATCH 83/88] fix trim_quotes --- .github/workflows/github-telegram.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 16d5e6a..1b1c041 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -49,6 +49,7 @@ jobs: - name: Prepare commit messages id: prepare run: | + source ./.github/scripts/sh/utils.sh source ./.github/scripts/sh/prepare_commits.sh total_parts=$(prepare_commits \ "${{ github.event.repository.name }}" \ @@ -62,6 +63,7 @@ jobs: - name: Send messages to Telegram if: ${{ steps.prepare.outputs.total_parts != '0' }} run: | + source ./.github/scripts/sh/utils.sh source ./.github/scripts/sh/send_telegram.sh send_telegram_messages \ "${{ secrets.TELEGRAM_TOKEN }}" \ From 03107fdcfd55c6c2113c184adf51aafdc62d60b6 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 23:17:46 +0700 Subject: [PATCH 84/88] fix readarray --- .github/scripts/sh/prepare_commits.sh | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/scripts/sh/prepare_commits.sh b/.github/scripts/sh/prepare_commits.sh index 39e124d..c1ed5a7 100755 --- a/.github/scripts/sh/prepare_commits.sh +++ b/.github/scripts/sh/prepare_commits.sh @@ -30,15 +30,11 @@ prepare_commits() { git checkout HEAD || { echo "Error: Failed to checkout HEAD" >&2; return 1; } # Читаем вывод git log в массив - while IFS= read -r line; do - readarray+=("$line") - done < <(git log --pretty=format:"'%h' - %an, %ar : %s" "HEAD..${after_sha}") + readarray=("${(@f)$(git log --pretty=format:"%h - %an, %ar : %s" "HEAD..${after_sha}")}") COMPARE_HASH="${after_sha}" else # Читаем вывод git log в массив - while IFS= read -r line; do - readarray+=("$line") - done < <(git log --pretty=format:"'%h' - %an, %ar : %s" "${before_sha}..${after_sha}") + readarray=("${(@f)$(git log --pretty=format:"%h - %an, %ar : %s" "${before_sha}..${after_sha}")}") COMPARE_HASH="${before_sha}..${after_sha}" fi From be5409889ea8ce13eecb46f660d196eaa3c80992 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 23:23:48 +0700 Subject: [PATCH 85/88] fix readarray --- .github/scripts/sh/prepare_commits.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/sh/prepare_commits.sh b/.github/scripts/sh/prepare_commits.sh index c1ed5a7..c1665ae 100755 --- a/.github/scripts/sh/prepare_commits.sh +++ b/.github/scripts/sh/prepare_commits.sh @@ -30,11 +30,11 @@ prepare_commits() { git checkout HEAD || { echo "Error: Failed to checkout HEAD" >&2; return 1; } # Читаем вывод git log в массив - readarray=("${(@f)$(git log --pretty=format:"%h - %an, %ar : %s" "HEAD..${after_sha}")}") + mapfile -t readarray < <(git log --pretty=format:"%h - %an, %ar : %s" "HEAD..${after_sha}") COMPARE_HASH="${after_sha}" else # Читаем вывод git log в массив - readarray=("${(@f)$(git log --pretty=format:"%h - %an, %ar : %s" "${before_sha}..${after_sha}")}") + mapfile -t readarray < <(git log --pretty=format:"%h - %an, %ar : %s" "${before_sha}..${after_sha}") COMPARE_HASH="${before_sha}..${after_sha}" fi From f22198c1d93b093dd538fa80364a95724aab320a Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 23:29:26 +0700 Subject: [PATCH 86/88] Update test.sh --- .github/scripts/sh/test.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/scripts/sh/test.sh b/.github/scripts/sh/test.sh index 3dce433..e8a3c9c 100755 --- a/.github/scripts/sh/test.sh +++ b/.github/scripts/sh/test.sh @@ -1,3 +1,5 @@ +#!/usr/bin/env bash + # Функция для отображения справки function show_help() { echo "Usage: $0 [OPTIONS]" From 559d028c6e039d399a496384dcf4877512df1318 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 23:31:24 +0700 Subject: [PATCH 87/88] rename test --- .github/scripts/sh/{test.sh => telegram_test.sh} | 0 package.json | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/scripts/sh/{test.sh => telegram_test.sh} (100%) diff --git a/.github/scripts/sh/test.sh b/.github/scripts/sh/telegram_test.sh similarity index 100% rename from .github/scripts/sh/test.sh rename to .github/scripts/sh/telegram_test.sh diff --git a/package.json b/package.json index ac6aa44..e7bc882 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "[github pages](https://alexsab.github.io)", "main": "index.js", "scripts": { - "prepare_commits": "./.github/scripts/sh/test.sh --prepare_commits", - "send_telegram": "./.github/scripts/sh/test.sh --send_telegram" + "prepare_commits": "./.github/scripts/sh/telegram_test.sh --prepare_commits", + "send_telegram": "./.github/scripts/sh/telegram_test.sh --send_telegram" }, "author": "Alexsab.ru", "license": "ISC" From 5b582188077b86e66247c5c9cc63ff86f389fac7 Mon Sep 17 00:00:00 2001 From: Alexander Sabanov Date: Sat, 4 Jan 2025 23:33:55 +0700 Subject: [PATCH 88/88] disable log-github-event-goodies --- .github/workflows/github-telegram.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/github-telegram.yml b/.github/workflows/github-telegram.yml index 1b1c041..f02874f 100644 --- a/.github/workflows/github-telegram.yml +++ b/.github/workflows/github-telegram.yml @@ -192,10 +192,10 @@ jobs: ${{ steps.get_commits.outputs.message }} - log-github-event-goodies: - name: "LOG Everything on GitHub Event" - runs-on: ubuntu-latest - steps: - - name: Logging - run: | - echo "${{ toJSON( github.event ) }}" + # log-github-event-goodies: + # name: "LOG Everything on GitHub Event" + # runs-on: ubuntu-latest + # steps: + # - name: Logging + # run: | + # echo "${{ toJSON( github.event ) }}"