PR์์ ํ๋ก์ ํธ Week ์ค์  ๋๋ฝ์ ๋ฐฉ์ง๋ฅผ ์ํ CI ์ค์  #5534
Workflow file for this run
  
    
      This file contains hidden or 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: Integration ๐ | |
| on: | |
| pull_request: | |
| jobs: | |
| linelint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| # PR ๋ผ๋ฒจ ํ์ธ | |
| - name: Get PR labels | |
| id: pr-labels | |
| run: | | |
| echo "๐ PR ๋ฒํธ: ${{ github.event.pull_request.number }}" | |
| pr_number="${{ github.event.pull_request.number }}" | |
| echo "๐ PR ๋ผ๋ฒจ ์กฐํ ์ค..." | |
| labels_json=$(gh pr view $pr_number --json labels -q '.labels[].name') | |
| echo "ํ์ธ๋ ๋ผ๋ฒจ: $labels_json" | |
| if [ -n "$labels_json" ]; then | |
| has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false') | |
| echo "maintenance ๋ผ๋ฒจ ํฌํจ ์ฌ๋ถ: $has_maintenance" | |
| echo "has_maintenance=$has_maintenance" >> $GITHUB_OUTPUT | |
| else | |
| echo "maintenance ๋ผ๋ฒจ์ด ์๋ PR์ ๋๋ค. ํ์ผ๋ช ๊ท์น ๊ฒ์ฌ๋ฅผ ์งํํฉ๋๋ค." | |
| echo "has_maintenance=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| # ์ค๋ฐ๊ฟ ์ฒดํฌ | |
| - name: Check for missing end line breaks | |
| run: | | |
| echo "๐ ์ค๋ฐ๊ฟ ๊ฒ์ฌ ์์" | |
| echo "๊ธฐ์ค ์ปค๋ฐ: ${{ github.event.pull_request.base.sha }}" | |
| echo "ํ์ฌ ์ปค๋ฐ: ${{ github.sha }}" | |
| files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"') | |
| success=true | |
| echo "๐ ๋ณ๊ฒฝ๋ ํ์ผ ๋ชฉ๋ก:" | |
| echo "$files" | |
| echo "## ์ค๋ฐ๊ฟ ๋๋ฝ ํ์ผ" >> $GITHUB_STEP_SUMMARY | |
| for file in $files; do | |
| echo "๊ฒ์ฌ ์ค: $file" | |
| if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then | |
| echo "โ ์ค๋ฐ๊ฟ ๋๋ฝ: $file" | |
| echo "- $file" >> $GITHUB_STEP_SUMMARY | |
| success=false | |
| else | |
| echo "โ ์ ์: $file" | |
| fi | |
| done | |
| if [ "$success" = false ]; then | |
| echo "โ ๏ธ ์ค๋ฐ๊ฟ ๊ฒ์ฌ ์คํจ" | |
| echo -e "\n:warning: ํ์ผ ๋์ ๋๋ฝ๋ ์ค๋ฐ๊ฟ์ ์ถ๊ฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| else | |
| echo "โ ๋ชจ๋ ํ์ผ์ ์ค๋ฐ๊ฟ ์ ์" | |
| fi | |
| # ์ ์ด๋ฌธ์ ์ฒดํฌ | |
| - name: Check for control characters in filenames | |
| run: | | |
| echo "๐ ํ์ผ๋ช ์ ์ด๋ฌธ์ ๊ฒ์ฌ ์์" | |
| files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"') | |
| success=true | |
| echo "## ์ ์ด๋ฌธ์๊ฐ ํฌํจ๋ ํ์ผ๋ช " >> $GITHUB_STEP_SUMMARY | |
| for file in $files; do | |
| echo "๊ฒ์ฌ ์ค: $file" | |
| # basename์ผ๋ก ํ์ผ๋ช ๋ง ์ถ์ถํ๊ณ ๋ฐ์ดํ ์ ๊ฑฐ | |
| filename=$(basename "$file" | tr -d '"') | |
| # ๋ฐฑ์ฌ๋์๋ก ์์ํ๋ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ (\b, \n, \r, \t ๋ฑ) | |
| if printf '%q' "$filename" | grep -q '\\[bnrtfv]' || \ | |
| # ์ผ๋ฐ์ ์ธ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ (0x00-0x1F, 0x7F) | |
| echo -n "$filename" | LC_ALL=C grep -q '[[:cntrl:]]' || \ | |
| # ํน์ ์ ์ด๋ฌธ์๋ค ์ฒดํฌ | |
| echo -n "$filename" | grep -q $'[\x00-\x1F\x7F]' || \ | |
| # ์ด์ค์ผ์ดํ ์ํ์ค ์ฒดํฌ | |
| [[ "$filename" =~ (\\[0-7]{1,3}|\\x[0-9a-fA-F]{1,2}) ]]; then | |
| echo "โ ์ ์ด๋ฌธ์ ๋ฐ๊ฒฌ: $file" | |
| echo "- $file (์ ์ด๋ฌธ์ ํฌํจ)" >> $GITHUB_STEP_SUMMARY | |
| success=false | |
| else | |
| echo "โ ์ ์: $file" | |
| fi | |
| done | |
| if [ "$success" = false ]; then | |
| echo "โ ๏ธ ์ ์ด๋ฌธ์ ๊ฒ์ฌ ์คํจ" | |
| echo -e "\n:warning: ํ์ผ๋ช ์์ ์ ์ด๋ฌธ์๋ฅผ ์ ๊ฑฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| else | |
| echo "โ ๋ชจ๋ ํ์ผ๋ช ์ด ์ ์ด๋ฌธ์ ์์ด ์ ์" | |
| fi | |
| # ํ์ผ๋ช ๊ท์น ์ฒดํฌ - maintenance ๋ผ๋ฒจ์ด ์๋ ๊ฒฝ์ฐ์๋ง ์คํ | |
| - name: Check filename rules | |
| if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }} | |
| run: | | |
| echo "๐ ํ์ผ๋ช ๊ท์น ๊ฒ์ฌ ์์" | |
| echo "PR ์์ฑ์: ${{ github.event.pull_request.user.login }}" | |
| # PR์ ๊ณตํต ์กฐ์ ์ปค๋ฐ์ ์ฐพ์์ merge base๋ก ์ค์  | |
| merge_base=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) | |
| echo "Merge base ์ปค๋ฐ: $merge_base" | |
| files=$(git diff --name-only $merge_base ${{ github.event.pull_request.head.sha }} | tr -d '"') | |
| pr_author="${{ github.event.pull_request.user.login }}" | |
| success=true | |
| echo "๐ ๊ฒ์ฌํ ํ์ผ ๋ชฉ๋ก:" | |
| echo "$files" | |
| echo "## ํ์ผ๋ช ๊ท์น ์๋ฐ" >> $GITHUB_STEP_SUMMARY | |
| for file in $files; do | |
| if [ -f "$file" ]; then | |
| echo "๊ฒ์ฌ ์ค: $file" | |
| # ํ์ผ๋ช ๋ง ์ถ์ถ (๊ฒฝ๋ก ์ ์ธ) | |
| filename=$(basename "$file") | |
| # ํ์ผ๋ช ์ด GitHub๊ณ์ ๋ช ์ธ์ง ํ์ธ | |
| shopt -s nocasematch | |
| if [[ ! "$filename" = "$pr_author"* ]]; then | |
| echo "โ ๊ท์น ์๋ฐ: $file" | |
| echo "- $file" >> $GITHUB_STEP_SUMMARY | |
| success=false | |
| else | |
| echo "โ ์ ์: $file" | |
| fi | |
| fi | |
| done | |
| if [ "$success" = false ]; then | |
| echo "โ ๏ธ ํ์ผ๋ช ๊ท์น ๊ฒ์ฌ ์คํจ" | |
| echo -e "\n:warning: ํ์ผ๋ช ์ ๋ฐ๋์ 'GitHub๊ณ์ ๋ช ' ๋๋ 'GitHub๊ณ์ ๋ช -xxx' ํ์์ผ๋ก ํด์ฃผ์ ์ผ ํฉ๋๋ค. (์: ${pr_author}.ts, ${pr_author}-1.ts, ${pr_author}-2.ts)" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| else | |
| echo "โ ๋ชจ๋ ํ์ผ๋ช ์ด ๊ท์น์ ๋ง๊ฒ ์ ์" | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| check-project: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| steps: | |
| # PR ๋ผ๋ฒจ ํ์ธ | |
| - name: Get PR labels | |
| id: pr-labels | |
| run: | | |
| echo "๐ PR ๋ฒํธ: ${{ github.event.pull_request.number }}" | |
| pr_number="${{ github.event.pull_request.number }}" | |
| echo "๐ PR ๋ผ๋ฒจ ์กฐํ ์ค..." | |
| labels_json=$(gh pr view $pr_number --json labels -q '.labels[].name') | |
| echo "ํ์ธ๋ ๋ผ๋ฒจ: $labels_json" | |
| if [ -n "$labels_json" ]; then | |
| has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false') | |
| echo "maintenance ๋ผ๋ฒจ ํฌํจ ์ฌ๋ถ: $has_maintenance" | |
| echo "has_maintenance=$has_maintenance" >> $GITHUB_OUTPUT | |
| else | |
| echo "maintenance ๋ผ๋ฒจ์ด ์๋ PR์ ๋๋ค. Week ์ค์ ์ ๊ฒ์ฌํฉ๋๋ค." | |
| echo "has_maintenance=false" >> $GITHUB_OUTPUT | |
| fi | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| # Week ์ค์  ํ์ธ | |
| - name: Check Week setting in project | |
| if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }} | |
| run: | | |
| echo "๐ Week ์ค์  ๊ฒ์ฌ ์์" | |
| pr_number="${{ github.event.pull_request.number }}" | |
| echo "๐ ํ๋ก์ ํธ ์ ๋ณด ์กฐํ ์ค..." | |
| project_data=$(gh api graphql -f query=' | |
| query { | |
| repository(owner: "${{ github.repository_owner }}", name: "${{ github.event.repository.name }}") { | |
| pullRequest(number: '$pr_number') { | |
| projectItems(first: 10) { | |
| nodes { | |
| project { | |
| title | |
| } | |
| fieldValues(first: 20) { | |
| nodes { | |
| __typename | |
| ... on ProjectV2ItemFieldIterationValue { | |
| title | |
| field { | |
| ... on ProjectV2FieldCommon { | |
| name | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| ' 2>&1) | |
| if [ $? -ne 0 ]; then | |
| echo "โ ๏ธ ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์ฌ ์ ์์ต๋๋ค." | |
| echo "$project_data" | |
| echo "## โ Week ์ค์  ๊ฒ์ฆ ์คํจ" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "ํ๋ก์ ํธ ์ ๋ณด๋ฅผ ์กฐํํ ์ ์์ต๋๋ค. PR์ด ํ๋ก์ ํธ์ ์ถ๊ฐ๋์๋์ง ํ์ธํด์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi | |
| echo "ํ๋ก์ ํธ ๋ฐ์ดํฐ:" | |
| echo "$project_data" | |
| # Week ํ๋ ๊ฐ ์ถ์ถ (Iteration ํ์ ์ Week ํ๋) | |
| week_value=$(echo "$project_data" | jq -r ' | |
| .data.repository.pullRequest.projectItems.nodes[].fieldValues.nodes[] | | |
| select(.__typename == "ProjectV2ItemFieldIterationValue") | | |
| select(.field.name == "Week") | | |
| .title | |
| ' 2>/dev/null | head -n 1) | |
| echo "์ถ์ถ๋ Week ๊ฐ: '$week_value'" | |
| if [ -z "$week_value" ] || [ "$week_value" = "null" ]; then | |
| echo "## โ Week ์ค์  ๊ฒ์ฆ ์คํจ" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "โ ๏ธ **PR์ Week ์ค์ ์ด ๋๋ฝ๋์์ต๋๋ค!**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### ์ค์  ๋ฐฉ๋ฒ" >> $GITHUB_STEP_SUMMARY | |
| echo "1. PR ์ฐ์ธก์ \`Projects\` ์น์ ์์ \`๋ฆฌํธ์ฝ๋ ์คํฐ๋\` ์ ๋๋กญ๋ค์ด(โผ) ํด๋ฆญ" >> $GITHUB_STEP_SUMMARY | |
| echo "2. ํ์ฌ ์ฃผ์ฐจ๋ฅผ ์ ํํด์ฃผ์ธ์ (์: \`Week 14(current)\` ๋๋ \`Week 14\`)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "๐ [์์ธํ ๊ฐ์ด๋ ๋ณด๊ธฐ](https://github.com/DaleStudy/leetcode-study/wiki/%EB%8B%B5%EC%95%88-%EC%A0%9C%EC%B6%9C-%EA%B0%80%EC%9D%B4%EB%93%9C#pr-%EC%9E%91%EC%84%B1%EB%B2%95)" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| fi | |
| echo "## โ Week ์ค์  ๊ฒ์ฆ ์ฑ๊ณต" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Week ์ค์ : **$week_value**" >> $GITHUB_STEP_SUMMARY | |
| echo "โ Week ์ค์ ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๋์ด ์์ต๋๋ค!" | |
| env: | |
| GH_TOKEN: ${{ github.token }} |