Skip to content

Commit

Permalink
build(dependabot): ⚡️ add action to enhance deps pr
Browse files Browse the repository at this point in the history
  • Loading branch information
yi-Xu-0100 committed Mar 21, 2021
1 parent 67b97b1 commit 4cd02eb
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/enhance-deps-pr.yml
Original file line number Diff line number Diff line change
@@ -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/[email protected]
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

0 comments on commit 4cd02eb

Please sign in to comment.