-
Notifications
You must be signed in to change notification settings - Fork 5
54 lines (47 loc) · 1.7 KB
/
enhance-deps-pr.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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@v3
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