diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 545ec296cd..fb54787aa9 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -71,13 +71,15 @@ jobs: - name: commit run: | if [ "${{ github.event_name }}" = "pull_request" ]; then - echo "commit='${{ github.event.head_commit.message }}'" >> $GITHUB_ENV + text="${{ github.event.head_commit.message }}" else mkdir -p ${{ github.workspace }}/git_clone git clone ${{ github.server_url }}/${{ github.repository }} ${{ github.workspace }}/git_clone -b ${{ github.ref_name }} cd ${{ github.workspace }}/git_clone - echo "commit='$(git log ${{ github.event.before }}..${{ github.event.after }} --pretty=format:'%h %s')'" >> $GITHUB_ENV + text="$(git log ${{ github.event.before }}..${{ github.event.after }} --pretty=format:'%h %s')" fi + echo "commit=$(echo $text | gawk '{gsub(/[_*[\]()~`>#+=\|{}.!-]/,"\\\\\\\\&")}1' | sed -e 's|"|\\"|g' -e 's|^[0-9a-z]\+|__&__|' | hexdump -v -e '/1 "%02X"' | sed 's/\(..\)/%\1/g')" >> $GITHUB_ENV + - name: Post to Canary Channel if: ${{ github.event_name != 'pull_request' && github.ref == 'refs/heads/main' && github.ref_type != 'tag' && contains(github.event.head_commit.message, '[skip post]') == false && contains(github.event.head_commit.message, 's#') == false }} @@ -94,6 +96,6 @@ jobs: by ${{ github.event.head_commit.author.name }} See commit detail [here](${{ github.event.head_commit.url }}) run: | - ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"].replace(".", r"\."))))') + ESCAPED=$(python3 -c 'import json,os,urllib.parse; print(urllib.parse.quote(json.dumps(os.environ["COMMIT_MESSAGE"])))') cd ${{ github.workspace }} curl -v "https://api.telegram.org/bot${BOT_TOKEN}/sendMediaGroup?chat_id=${CHANNEL_ID}&media=%5B%7B%22type%22:%22document%22,%20%22media%22:%22attach://canary%22,%22parse_mode%22:%22MarkdownV2%22,%22caption%22:${ESCAPED}%7D%5D" -F canary="@${CANARY}"