|
1 | 1 | name: Dependabot Pull Request Approve and Merge
|
2 |
| -on: pull_request_target |
| 2 | +on: pull_request #_target |
3 | 3 | permissions:
|
4 | 4 | pull-requests: write
|
5 | 5 | contents: write
|
6 | 6 | jobs:
|
| 7 | + pull-request-title-change: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + # Checkout the source code |
| 11 | + - name: 'Checkout source code' |
| 12 | + uses: actions/checkout@v4 |
| 13 | + |
| 14 | + - name: 'Fetch Dependabot metadata' |
| 15 | + id: dependabot-fetch |
| 16 | + uses: dependabot/fetch-metadata@v1 |
| 17 | + |
| 18 | + - name: 'Split title and update' |
| 19 | + id: split-title |
| 20 | + if: ${{ ! contains(github.event.pull_request.title, '):' ) && contains(github.event.pull_request.title, ':') && steps.dependabot-fetch.outcome == 'success' }} |
| 21 | + env: |
| 22 | + TITLE: ${{ github.event.pull_request.title }} |
| 23 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 24 | + PR_URL: ${{github.event.pull_request.html_url}} |
| 25 | + run: | |
| 26 | + echo $TITLE |
| 27 | + title_pt2="${TITLE##*:}" |
| 28 | + title_pt1="${TITLE%%:*}" |
| 29 | + gh pr checkout "$PR_URL" # sets the upstream metadata for `gh pr status` |
| 30 | + packagename="${{ steps.dependabot-fetch.outputs.dependency-names }}" |
| 31 | + #echo "packagename is $packagename" |
| 32 | + #echo "$title_pt1" |
| 33 | + #echo "$title_pt2" |
| 34 | + parensOpen="(" |
| 35 | + parensClose="):" |
| 36 | + pr_title=$title_pt1$parensOpen$packagename$parensClose$title_pt2 |
| 37 | + echo "FINAL TITLE: $pr_title" |
| 38 | + gh pr edit "$PR_URL" --title "$pr_title" |
| 39 | +
|
7 | 40 | # Auto merge Dependabot PRs for:
|
8 | 41 | # - patch updates on prod dependencies
|
9 | 42 | # - minor updates on dev dependencies
|
10 | 43 | dependabot-auto-merge:
|
| 44 | + needs: pull-request-title-change |
11 | 45 | # Only run for Dependabot PRs
|
12 | 46 | if: ${{ github.actor == 'dependabot[bot]' }}
|
13 | 47 | runs-on: ubuntu-latest
|
|
0 commit comments