diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml index d168d81..b8fc19e 100644 --- a/.gitea/workflows/demo.yaml +++ b/.gitea/workflows/demo.yaml @@ -1,6 +1,9 @@ name: Gitea Actions Demo run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀 on: + pull_request: + branches: ["main"] + types: [closed] # 当pull request被合并或关闭时触发。这包括两种情况:一是pull request被合并(merged),二是pull request被直接关闭(closed) push: branches: [ "main","releases/**" ] # paths: @@ -46,6 +49,18 @@ jobs: echo "不包含" exit 1 fi + - name: Get commit message (Pull Request) + if: github.event_name == 'pull_request' + run: | + echo "是否是合并关闭的 $PR_STATUS_FLAG" + pr_num=${{ github.event.pull_request.number }} + git fetch origin refs/pull/${pr_num}/head:refs/remotes/origin/pull/${pr_num}/head + commit_title=$(git log -1 --pretty=format:"%s" origin/pull/${pr_num}/head) + commit_body=$(git log -1 --pretty=format:"%b" origin/pull/${pr_num}/head) + echo "合并请求 Commit Title: $commit_title" + echo "合并请求Commit Body: $commit_body" + env: + PR_STATUS_FLAG: ${{ github.event.pull_request.merged }} - run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event." - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"