From 4cd02ebe5bbe1ef576cab9d4a6b70dcca29a04e2 Mon Sep 17 00:00:00 2001 From: yi_Xu Date: Sun, 21 Mar 2021 08:39:33 +0800 Subject: [PATCH] =?UTF-8?q?build(dependabot):=20=E2=9A=A1=EF=B8=8F=20add?= =?UTF-8?q?=20action=20to=20enhance=20deps=20pr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/enhance-deps-pr.yml | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/enhance-deps-pr.yml diff --git a/.github/workflows/enhance-deps-pr.yml b/.github/workflows/enhance-deps-pr.yml new file mode 100644 index 0000000..7230bc1 --- /dev/null +++ b/.github/workflows/enhance-deps-pr.yml @@ -0,0 +1,54 @@ +name: 'enhance deps PR' + +on: + pull_request_target: + types: [labeled] + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + run: + name: enhance deps PR + runs-on: ubuntu-latest + if: contains(github.event.pull_request.labels.*.name, 'dependencies') + steps: + - name: Checkout code + uses: actions/checkout@v2.3.4 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - name: Echo PR information + run: | + echo "[info] PR number: ${{ github.event.pull_request.number }}" + echo "[info] PR title: ${{ github.event.pull_request.title }}" + echo "[info] head ref: ${{ github.head_ref }}" + + - name: Check PR context + id: check + run: | + echo "${{ github.event.pull_request.title }}" | \ + sed -e "s/^chore.*: \(.*\)/\1/" | \ + sed -e "s/^/chore(deps): ⬆️ /" | \ + xargs echo "::set-output name=title::$1" + git log --pretty=format:"%b" -1 | \ + xargs echo "::set-output name=body::$1" + + - name: Enhance PR title + env: + number: ${{ github.event.pull_request.number }} + title: ${{ steps.check.outputs.title }} + run: | + gh pr edit ${{ env.number }} --title "${{ env.title }}" + + - name: Enhance PR commit message + env: + number: ${{ github.event.pull_request.number }} + title: ${{ steps.check.outputs.title }} + body: ${{ steps.check.outputs.body }} + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + git commit --amend -m "${{ env.title }}" -m "${{ env.body }}" + git push -f \ No newline at end of file