π Create pull request #236
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: π 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 | |
- [ ] λΉλ νκ²½ νμΈ | |
- [ ] μ½λ 리뷰 | |
- [ ] ν μ€νΈ λΉλ | |
- [ ] ν μ€νΈ λ°°ν¬` | |
}) |