Pull Request Event #29
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
pull_request: | |
types: [opened, reopened, closed] | |
pull_request_review: | |
types: [submitted, dismissed] | |
env: # 统一设置环境变量 | |
WEBHOOK: https://open.feishu.cn/open-apis/bot/v2/hook/bfba47d7-7368-43f1-b339-a4aad6a6fbfc | |
WEBHOOK2: https://open.feishu.cn/open-apis/bot/v2/hook/7d45fa33-ad80-4443-b488-2446d9872583 | |
name: Pull Request Event | |
jobs: | |
curl: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: params | |
run: | | |
echo "sender=$GITHUB_ACTOR" >> $GITHUB_ENV | |
echo "webhook=$WEBHOOK" >> $GITHUB_ENV | |
echo "repo=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV | |
- name: curl | |
run: | | |
echo "Source Branch: ${{ github.event.pull_request.head.ref }}" | |
echo "Target Branch: ${{ github.event.pull_request.base.ref }}" | |
if [ "${{ github.event_name }}" == "pull_request" ]; then | |
for WEBHOOK in $WEBHOOK $WEBHOOK2; do | |
echo "pull_request: $WEBHOOK" | |
echo "Pull Request Action: ${{ github.event.action }}" | |
curl --location --header 'Content-Type: application/json' --data '{"msg_type":"interactive","card":{"type":"template","data":{"template_id":"ctp_AA14YlhE5N0u","template_variable":{"repo":"${{env.repo}}","headBranch":"${{github.event.pull_request.head.ref}}","actor":"${{github.actor}}","jump_url":"${{ github.event.pull_request.html_url }}","baseBranch":"${{github.event.pull_request.base.ref}}"}}}}' $WEBHOOK | |
done | |
else | |
if [ "${{ github.event.review.state }}" == "approved" ]; then | |
for WEBHOOK in $WEBHOOK $WEBHOOK2; do | |
curl --location --header 'Content-Type: application/json' --data '{"msg_type":"interactive","card":{"type":"template","data":{"template_id":"ctp_AA14jtBsjQrf","template_variable":{"repo":"${{env.repo}}","headBranch":"${{github.event.pull_request.head.ref}}","actor":"${{github.actor}}","jump_url":"${{ github.event.pull_request.html_url }}","approver":"${{github.event.pull_request_review.user.login}}","baseBranch":"${{github.event.pull_request.base.ref}}"}}}}' $WEBHOOK | |
done | |
fi | |
echo "pull_request_review: ${{ github.event.review.state }}" | |
fi |