Docs/feature/modify readme #54
Workflow file for this run
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: Configure PR When PR Opened | |
on: | |
pull_request: | |
types: | |
- opened | |
permissions: | |
contents: read | |
jobs: | |
check-title: | |
name: Check PR Title | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Check PR title | |
uses: deepakputhraya/action-pr-title@master | |
with: | |
regex: '((Be|Fe|Devops|Be,fe|Fe,be)\/(feature|bugfix|hotfix|refactor)(,(feature|bugfix|hotfix|refactor))*\/#[\d]+( #[\d]+)*.+|release v[\d]+\.[\d]+\.[\d]+)' | |
github_token: ${{ secrets.ADD_TO_PROJECT_PAT }} | |
set-label: | |
name: Set Labels to PR | |
needs: check-title | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- uses: TimonVS/pr-labeler-action@v5 | |
with: | |
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} | |
configuration-path: .github/pr-labels.yml | |
set-issue: | |
name: Set Issue to PR | |
needs: check-title | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
if: github.event.pull_request.base.ref != 'release' | |
with: | |
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} | |
script: | | |
const prTitle = context.payload.pull_request.title; | |
const issueNumbers = prTitle.match(/#(\d+)/g); | |
const prefix = issueNumbers ? issueNumbers.reduce((acc, curr) => `${acc}🔮 resolved ${curr}\n`, "") : ''; | |
const body = context.payload.pull_request.body.replace(/(🔮 resolved #\d+)+/g, ''); | |
github.rest.pulls.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: context.payload.number, | |
body: `${prefix}${body}`, | |
}); | |
issueNumbers?.forEach((num) => { | |
github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: num.replace('#', ''), | |
state: 'open', | |
}); | |
}); | |
set-assignee: | |
name: Set Assignee to PR | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/github-script@v7 | |
if: github.event.pull_request.base.ref != 'release' | |
with: | |
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }} | |
script: | | |
const sender = context.payload.sender.login; | |
const assignees = context.payload.pull_request.assignees; | |
const newAssignees = assignees ?? []; | |
newAssignees.push(sender); | |
github.rest.issues.addAssignees({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.payload.number, | |
assignees: newAssignees, | |
}); |