-
Notifications
You must be signed in to change notification settings - Fork 1
49 lines (43 loc) · 1.56 KB
/
pr-title-changer.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
name: Pull Request Title Modifier
on:
pull_request:
paths-ignore:
- src/**
- static/**
- tailwind.config.*
- package.json
env:
PREFIX: infra
jobs:
pr-title-modifier:
name: PR Title Modifier
runs-on: ubuntu-latest
if: github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.user.login != 'renovate[bot]' && github.event.pull_request.user.login != 'emeraldstudio-bot'
permissions:
pull-requests: write
steps:
- name: 📂 Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 2
- name: 📋 Count all changed files for this commit
id: infra-changed-files
run: |
count=$(git diff --name-only HEAD^ HEAD | grep -E '.github/|.husky/|.gitignore|LICENSE|README.md' | wc -l)
if [ $count -gt 0 ]; then
echo "$count infrastructure files changed in the last commit"
echo "infra_changes=true" >> $GITHUB_OUTPUT
else
echo "No infrastructure files changed in the last commit"
echo "infra_changes=false" >> $GITHUB_OUTPUT
fi
- name: 📝 Modify PR Title
if: steps.infra-changed-files.outputs.infra_changes == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
current_title=$(gh pr view --json title --jq '.title')
if [[ $current_title != "${{ env.PREFIX }}: "* ]]; then
gh pr edit --title "${{ env.PREFIX }}: $current_title"
fi