Skip to content

πŸš€ Create pull request #236

πŸš€ Create pull request

πŸš€ Create pull request #236

name: πŸš€ Create pull request
on:
workflow_dispatch :
inputs :
branch :
type : choice
description : 'Branch to create pull request'
options:
[ 'major', 'release', 'hotfix' ]
required : true
jobs:
# 버전 λ³€κ²½ μš”μ²­μΈ κ²½μš°μ—λ§Œ, 버전을 변경함.
change-version:
name : πŸš€ Change release version
runs-on: ubuntu-latest
if: contains(fromJson('["release", "hotfix", "major"]'), github.event.inputs.branch)
outputs:
version: ${{ steps.update-version.outputs.version }}
branch: release/${{ steps.update-version.outputs.version }}
steps :
- name : πŸš€ κΉƒ 정보 λ‘œλ”©
uses: actions/checkout@v3
with :
ref : develop
- name: βœ… Check And Set Node Version
id : update-version
run: |
version=$(node -p 'require("./package.json").version')
major=$(echo $version | cut -d. -f1)
release=$(echo $version | cut -d. -f2)
hotfix=$(echo $version | cut -d. -f3)
if [[ ${{ github.event.inputs.branch }} == 'major' ]]; then
# μ£Όμš” μ—…λ°μ΄νŠΈ
major=$((major+1))
release=0
hotfix=0
elif [[ ${{ github.event.inputs.branch }} == 'release' ]]; then
# κΈ°λŠ₯μ—…λ°μ΄νŠΈ
release=$((release+1))
hotfix=0
elif [[ ${{ github.event.inputs.branch }} == 'hotfix' ]]; then
# hotFix
hotfix=$((hotfix+1))
fi
version="$major.$release.$hotfix"
echo "version=${version}" >> $GITHUB_OUTPUT
shell: bash
change-version-commit:
name : πŸš€ Create release branch
needs: [ change-version ]
runs-on: ubuntu-latest
# continue-on-error: true
strategy:
matrix:
node-version: [18.16.1]
steps :
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- uses: actions/checkout@v4
with:
ref : develop
- name : πŸš€ 릴리즈 버전 컀밋
run: |
git checkout -b ${{ needs.change-version.outputs.branch }}
git config --global user.email "github-actions@github.com"
git config --global user.name "github-actions"
npm pkg set version="${{ needs.change-version.outputs.version }}"
git add package.json
git commit -m "πŸš€ Release version ${{ needs.change-version.outputs.version }}"
git push --set-upstream origin ${{ needs.change-version.outputs.branch }}
shell: bash
- name : ❗ 브런치 생성 μ‹€νŒ¨
if: failure()
run: |
echo "브런치 생성 μ‹€νŒ¨ - 이미 μ‘΄μž¬ν•˜λŠ” 브런치 ${{ needs.change-version.outputs.branch }} μž…λ‹ˆλ‹€."
git config pull.rebase false
git pull origin develop
git checkout ${{ needs.change-version.outputs.branch }}
echo "브런치 λ³€κ²½ μ™„λ£Œ ${{ needs.change-version.outputs.branch }}"
git pull origin ${{ needs.change-version.outputs.branch }} --allow-unrelated-histories
echo "브런치 pull μ™„λ£Œ"
git merge develop
echo "브런치 병합"
git push --set-upstream origin ${{ needs.change-version.outputs.branch }}
shell: bash
create-pr:
name : πŸš€ Create pull request
needs: [change-version, change-version-commit]
runs-on: ubuntu-latest
steps :
- uses: actions/checkout@v4
with:
ref : ${{ needs.change-version.outputs.branch }}
- name : πŸš€ κΉƒ 정보 λ‘œλ”©
run : |
git checkout ${{ needs.change-version.outputs.branch }}
- name : πŸš€ Create pull request
uses : actions/github-script@v6
with:
script: |
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Release. ${{ needs.change-version.outputs.version }}',
head: '${{ needs.change-version.outputs.branch }}',
base: 'master',
body: `# Release version ${{ needs.change-version.outputs.version }}
## Release branch
${{github.ref}}
## CheckList
- [ ] λΉŒλ“œ ν™˜κ²½ 확인
- [ ] μ½”λ“œ 리뷰
- [ ] ν…ŒμŠ€νŠΈ λΉŒλ“œ
- [ ] ν…ŒμŠ€νŠΈ 배포`
})