Skip to content

Commit

Permalink
修复pull_request时工作流读取commit报错
Browse files Browse the repository at this point in the history
  • Loading branch information
elysias123 authored Dec 2, 2023
1 parent a596ce7 commit e666a56
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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}"

0 comments on commit e666a56

Please sign in to comment.