[SCRUM-80] Notification Color 변경 #38
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: PR Template Selector | |
on: | |
pull_request: | |
types: [opened] | |
jobs: | |
apply-template: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Check Branch and Apply Template | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const fs = require('fs'); | |
const prBranch = context.payload.pull_request.head.ref; | |
const baseBranch = context.payload.pull_request.base.ref; | |
let templatePath = '.github/PULL_REQUEST_TEMPLATE/basic_template.md'; | |
if (prBranch.startsWith('release/') || prBranch.startsWith('hotfix/')) { | |
templatePath = '.github/PULL_REQUEST_TEMPLATE/release_template.md'; | |
} else if (baseBranch === 'develop') { | |
templatePath = '.github/PULL_REQUEST_TEMPLATE/basic_template.md'; | |
} | |
const template = fs.readFileSync(templatePath, 'utf8'); | |
await github.rest.pulls.update({ | |
...context.repo, | |
pull_number: context.payload.pull_request.number, | |
body: context.payload.pull_request.body ? `${template}\n\n---\n\n${context.payload.pull_request.body}` : template | |
}); |