-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathupdate-pull-request-description.yml
More file actions
44 lines (41 loc) · 1.7 KB
/
update-pull-request-description.yml
File metadata and controls
44 lines (41 loc) · 1.7 KB
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
name: "Update Pull Request description with Template"
on:
pull_request:
types: [opened]
branches-ignore:
- "dependabot/**"
permissions:
contents: read
pull-requests: write
jobs:
update-pull-request:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get Branch Name
uses: mdecoleman/pr-branch-name@v3.0.0
id: branch_name
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Get branch number
run: echo "BRANCH_NUMBER=$(echo ${{ steps.branch_name.outputs.branch }} | grep -Eo '[A-Za-z]{2,5}-[0-9]{1,5}')" >> $GITHUB_ENV
- name: Get branch designator
run: echo "BRANCH_DESIGNATOR=$(echo ${{ steps.branch_name.outputs.branch }} | sed 's|/.*||')" >> $GITHUB_ENV
- name: Get template name
run: echo "TEMPLATE_NAME=$(cat .github/PULL_REQUEST_TEMPLATE/${{ env.BRANCH_DESIGNATOR }}_pull_request_template.md > /dev/null 2>&1 && echo ${{ env.BRANCH_DESIGNATOR }}_pull_request_template.md || echo task_pull_request_template.md)" >> $GITHUB_ENV
- name: Render Pull Request template
id: template
uses: chuhlomin/render-template@v1.10
with:
template: .github/PULL_REQUEST_TEMPLATE/${{ env.TEMPLATE_NAME }}
vars: |
BRANCH_NUMBER: ${{ env.BRANCH_NUMBER }}
BRANCH_DESIGNATOR: ${{ env.BRANCH_DESIGNATOR }}
- uses: tzkhan/pr-update-action@v2
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
head-branch-regex: "${{ env.BRANCH_DESIGNATOR }}/.*"
body-template: ${{ steps.template.outputs.result }}
body-update-action: "replace"