feat(UploadFile): component bare structure WIP #304
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update PR Description | |
on: | |
pull_request: | |
types: [opened] | |
branches: | |
- main | |
jobs: | |
update-description: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update PR Description | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const branchName = context.payload.pull_request.head.ref; | |
const prNumber = context.payload.pull_request.number; | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
const { data: prData } = await github.rest.pulls.get({ | |
owner: owner, | |
repo: repo, | |
pull_number: prNumber | |
}); | |
let body = prData.body; | |
const issueNumberMatch = branchName.match(/feature\/(\d+)/); | |
const issueNumber = issueNumberMatch ? issueNumberMatch[1] : ''; | |
if (issueNumber) { | |
body = prData.body.replace(/{issue-number}/g, issueNumber); | |
} | |
const branchNameCropped = branchName.split('feature/')[1]; | |
body = prData.body.replace(/{branch-name}/g, branchNameCropped); | |
await github.rest.pulls.update({ | |
owner: owner, | |
repo: repo, | |
pull_number: prNumber, | |
body: body | |
}); |