๐Ÿšฟ ๊นƒํ—ˆ๋ธŒ ์ž”๋””์— ๋ฌผ ์ฃผ๊ธฐ(feat.๋ฐฑ์ค€ ๋ฌธ์ œ ์—…๋กœ๋“œ ์ž๋™ํ™”)

ํ—Œ์น˜ยท2022๋…„ 11์›” 30์ผ
22

์ž๋™ํ™”

๋ชฉ๋ก ๋ณด๊ธฐ
1/1

๊ด€๋ จ ๋ ˆํฌ

๋ฐฑ์ค€&ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ฌธ์ œํ’€์ด ์ž๋™ ๊ด€๋ฆฌ ๋ ˆํฌ์ง€ํ† ๋ฆฌ

1. ๋“ค์–ด๊ฐ€๋ฉฐ

์šฐํ…Œ์ฝ”๋ฅผ ์ˆ˜๋ฃŒํ•œ ํ›„, ์‹ฌ์‹ฌํ•ด์„œ ๊นƒํ—ˆ๋ธŒ ํŽ˜์ด์ง€๋ฅผ ๊พธ๋ฏธ๋ ค๋˜ ์ค‘ ์ถฉ๊ฒฉ์ ์ธ ์‚ฌ์‹ค์„ ์•Œ๊ฒŒ ๋œ๋‹ค...

์ปค๋ฐ‹ ๊ธฐ๋ก... ํ……ํ…… ๋น„์—ˆ๋‹ค!!๐Ÿ˜‚

์ƒ๊ฐํ•ด๋ณด๋‹ˆ ์–ต์šธํ–ˆ๋‹ค. ์ง€๊ธˆ๊นŒ์ง€ ๋งค์ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋„ ํ’€๊ณ , ๊ณต๋ถ€ํ•œ ๊ฒƒ๋“ค๋„ ๊ธฐ๋กํ–ˆ๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ’€์ด๋Š” ๋ฐฑ์ค€, ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์—์„œ ์ง„ํ–‰ํ–ˆ๊ณ  ๊ณต๋ถ€ ๊ธฐ๋ก์€ ๋…ธ์…˜์— ์žˆ๋‹ค๋ณด๋‹ˆ ์‹ค ์ปค๋ฐ‹๋“ค์ด ์ผ์ผ ๋‹จ์œ„๋กœ ์ด๋ค„์ง€์ง€ ์•Š์•„ ์ž”๋””๊ฐ€ ๋ง๋ผ ๋น„ํ‹€์–ด์ ธ ์žˆ์—ˆ๋‹ค...
(์•„๋‹ˆ ๋ฌผ๋ก  TIL์ด๋ผ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธํ’€๋กœ ์ปค๋ฐ‹์„ ์ฑ„์šด๋‹ค๋Š”๊ฒŒ ๋ณธ๋ง ์ „๋„๊ฐ™๊ธด ํ•œ๋ฐ... ๋‹ค๋“ค ๊ทธ๋ ‡๊ฒŒ ํ•˜์ž–์•„์š”?ใ…Ž)

2. ๋ฐฑ์ค€ ๋ฌธ์ œ ์ž๋™ ์ปค๋ฐ‹

๊ทธ๋ ‡๋‹ค๋ฉด... ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ๋ฅผ ํ’€ ๋•Œ๋งˆ๋‹ค ๊นƒํ—ˆ๋ธŒ ์ปค๋ฐ‹์œผ๋กœ ๋‚จ๊ธฐ๋ฉด ๋˜์ž–์•„?

์ฐพ์•„๋ณด๋‹ˆ ๋งˆ์นจ ์•„๋ฆ„๋‹ค์šด ํ”Œ๋Ÿฌ๊ทธ์ธ์ด ์žˆ์—ˆ๋‹ค. ๊ธฐ์กด LeetCodeHub ์˜ ํ•œ๊ตญํ˜• ํŠนํ™” ํ”Œ๋Ÿฌ๊ทธ์ธ์ธ BaekjoonHub ์ด๋‹ค.

๋ฐฑ์ค€ํ—ˆ๋ธŒ ํ”Œ๋Ÿฌ๊ทธ์ธ

๊ณต์‹ ์‚ฌ์šฉ๋ฒ•

์ด๋กœ์จ ๊นƒํ—ˆ๋ธŒ์— ์ž๋™ ์ปค๋ฐ‹์ด ๊ฐ€๋Šฅํ•ด์กŒ๋‹ค! ๊ฐœ๋ฐœ์ž๋‹˜ ๋ณต๋ฐ›์œผ์„ธ์š”๐Ÿ™‡โ€โ™€๏ธ

3. ๊ธฐ์กด ํ‘ผ ๋ฌธ์ œ๋“ค๋„ ๋ ˆํฌ๋กœ ์˜ฎ๊ธฐ์ž!๐Ÿš€

๊ธฐ์กด์— ํ’€์—ˆ๋˜ ๋ฐฑ์ค€ ๋ฌธ์ œ๋“ค๋„ ์†์‰ฝ๊ฒŒ ์˜ฎ๊ธธ ์ˆ˜ ์žˆ๋‹ค.
1. ํ”Œ๋Ÿฌ๊ทธ์ธ ํ™œ์„ฑํ™” ๋ฐ ๋ ˆํฌ ์„ธํŒ…
2. ๋ฐฑ์ค€ ๋งˆ์ดํŽ˜์ด์ง€์˜ ์ „์ฒด์ œ์ถœ ์—…๋กœ๋“œ(ํ‘œ์‹œํ•œ ๋ถ€๋ถ„)๋ฅผ ํด๋ฆญ
3. ๊ธฐ์กด์— ํ‘ผ ๋ชจ๋“  ๋ฌธ์ œ๋“ค ์—…๋กœ๋“œ!

๋‹ค๋งŒ ํ•ด๋‹น ๋ฐฉ๋ฒ•์€ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์—์„  ๋จนํžˆ์ง€ ์•Š์•˜๋‹ค. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค๋Š” ๋”ฐ๋กœ ์ด๋ฏธ ํ‘ผ ๋ฌธ์ œ๋“ค์„ ํ•˜๋‚˜์”ฉ ์žฌ ์ œ์ถœํ•ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค.

4. ๋ฆฌ๋“œ๋ฏธ๋ฅผ ์ž๋™์œผ๋กœ ๊พธ๋ฉฐ์ฃผ์ž...โœจ

๊ทธ๋ž˜! ์ž๋™ ์ปค๋ฐ‹ ์—ฐ๊ฒฐ๊นŒ์ง„ ์™„๋ฃŒ๋๋‹ค. ์•ž์œผ๋กœ์˜ ๊นƒํ—™ ์ž”๋””๋Š” ํ‘ธ๋ฅธ๊ธธ๋งŒ ๊ฑธ์„ ๊ฒƒ์ด๋‹ค!(๊ณผ์—ฐ?)

ํ•˜์ง€๋งŒ ์•„์ง ๋ถˆํŽธํ•˜๋‹ค. ํ‘ผ ๋ฌธ์ œ๊ฐ€ ํ‘ธ์‹œ๋  ๋•Œ๋งˆ๋‹ค README.md๊ฐ€ ์ด์˜๊ฒŒ ๊ด€๋ฆฌ๋˜๋ฉด ์–ผ๋งˆ๋‚˜ ์ข‹์„๊นŒ!! ํ•˜์ง€๋งŒ ํ˜„์žฌ๋กœ์ฌ ๋ฆฌ๋“œ๋ฏธ๋ฅผ ์ˆ˜๋™์œผ๋กœ ๊พธ๋ฉฐ์ค˜์•ผ๋งŒ ํ•œ๋‹ค.

์ด์— github actions๋กœ ์ปค๋ฐ‹ํ•  ๋•Œ๋งˆ๋‹ค ์›ํ•˜๋Š” ํฌ๋งท์œผ๋กœ ๋ฆฌ๋“œ๋ฏธ๋ฅผ ์ž๋™ ์ƒ์„ฑํ•ด์ฃผ๋„๋ก ์„ค์ •ํ–ˆ๋‹ค.

0) GitHub Actions๊ฐ€ ๋ญ”๋ฐ?

ํ˜„์žฌ๋กœ์„  ์ด๊ฒƒ๋งŒ ์•Œ๋ฉด ๋œ๋‹ค.

์šฐ๋ฆฌ์˜ ์†Œ์ค‘ํ•œ ๊นƒํ—ˆ๋ธŒ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ ˆํฌ์— ์ž๋™ ์ปค๋ฐ‹๋  ๋•Œ(ํŠน์ • ๋™์ž‘ ๋ฐœ์ƒ)๋งˆ๋‹ค (workflow์—) ๋ฏธ๋ฆฌ ์ง€์ •๋œ ์•ก์…˜์ด ์ž๋™ ์ˆ˜ํ–‰๋˜๋Š” ๊ธฐ๋Šฅ

๋ณดํ†ต ํ”Œ์  CI/CD๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ํˆด์ด๋‹ค. ์šฐ๋ฆฌ ์†๋‹ฅ์†๋‹ฅ ํ”„๋กœ์ ํŠธ์—์„œ๋„ ์‚ฌ์šฉ๋˜์—ˆ์—ˆ๋‹ค.

1) ์ผ๋‹จ ์ž๋™์ƒ์„ฑ ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ ์ž!

Action ํƒญ์—์„œ Python package๋ฅผ ๋ˆ„๋ฅธ๋‹ค.

.github/workflows ํด๋”๊ฐ€ ์ƒ๊ฒผ์„ ๊ฒƒ์ด๋‹ค.


๋‚ด๋ถ€ yml ํŒŒ์ผ์„ ์ง€์šฐ๊ณ  ์•„๋ฌด ์ด๋ฆ„์ด๋‚˜ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ์ด๋ฆ„์˜ yml ํŒŒ์ผ์„ ๋งŒ๋“ ๋‹ค.

๋‚˜๋Š” update-readme.yml ํŒŒ์ผ์„ ์ถ”๊ฐ€ํ–ˆ๋‹ค.
๋‚ด์šฉ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

(์ฃผ์˜ : build-run์—์„œ git ์œ ์ €๋ช…, ์œ ์ €์ด๋ฉ”์ผ์€ ๊ฐ์ž ๊นƒํ—™์— ๋งž๊ฒŒ ์žฌ์„ค์ •์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค!!)

# ์ด ์›Œํฌํ”Œ๋กœ์šฐ๋Š” update.py ํŒŒ์ผ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ README.md ํŒŒ์ผ์„ ์—…๋ฐ์ดํŠธํ•ฉ๋‹ˆ๋‹ค.

name: Update readme # GitHub Actions ํƒญ์—์„œ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋Š” ์•ก์…˜ ์ด๋ฆ„

on: # jobs๊ฐ€ ์‹คํ–‰๋˜์–ด์•ผ ํ•˜๋Š” ์ƒํ™ฉ ์ •์˜
  push:
    branches: [ "main" ] # main ๋ธŒ๋žœ์น˜์— push๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๋•Œ
  pull_request:

jobs: # ์‹ค์ œ ์‹คํ–‰๋  ๋‚ด์šฉ
  build:
    runs-on: ubuntu-latest # ๋นŒ๋“œ ํ™˜๊ฒฝ
    steps:
    - uses: actions/checkout@v3 # checkout
    - name: Set up Python 3.10 
      uses: actions/setup-python@v3 # setup-python
      with:
        python-version: "3.10" # 3.10๋ฒ„์ „ ํŒŒ์ด์ฌ ์‚ฌ์šฉ
    - name: Install dependencies # 1) ์Šคํฌ๋ฆฝํŠธ์— ํ•„์š”ํ•œ dependency ์„ค์น˜
      run: |
        python -m pip install --upgrade pip
        pip install python-leetcode 
    - name: Run update.py # 2) update.py ์‹คํ–‰
      run: |
        python update.py
    - name: Commit changes # 3) ์ถ”๊ฐ€๋œ ํŒŒ์ผ commit
      run: |
        git config --global user.name 'BETTERFUTURE4' # ์œ ์ €๋ช…
        git config --global user.email 'rerub0831@gmail.com' # ์œ ์ € ์ด๋ฉ”์ผ
        git add -A
        git commit -am "auto update README.md" # ์ปค๋ฐ‹ ๋ฉ”์‹œ์ง€
    - name: Push changes # 4) ๋ฉ”์ธ์— ํ‘ธ์‹œ
      run: |
        git push

2) ํ…Œ์ด๋ธ” ํ˜•ํƒœ๋กœ ์—…๋ฐ์ดํŠธํ• ๋ž˜์š”

๊ทธ๋ฆฌ๊ณ  ๋ฉ”์ธ ๋ฃจํŠธ์ชฝ์— ์ปค๋ฐ‹ ํ›„๋งˆ๋‹ค ์‹คํ–‰๋  update.py ํŒŒ์ผ์„ ๋งŒ๋“ ๋‹ค.

๋‹ค์Œ์€ update.py ์ด๋‹ค.

#!/usr/bin/env python

import os
from urllib import parse

HEADER="""# 
# ๋ฐฑ์ค€ & ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ฌธ์ œ ํ’€์ด ๋ชฉ๋ก

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฒฝ์šฐ, ํ‘ผ ๋ฌธ์ œ ๋ชฉ๋ก์— ๋Œ€ํ•œ ๋งˆ์ด๊ทธ๋ ˆ์ด์…˜์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค.

"""

def main():
    content = ""
    content += HEADER
    
    directories = [];
    solveds = [];

    for root, dirs, files in os.walk("."):
        dirs.sort()
        if root == '.':
            for dir in ('.git', '.github'):
                try:
                    dirs.remove(dir)
                except ValueError:
                    pass
            continue

        category = os.path.basename(root)
        
        if category == 'images':
            continue
        
        directory = os.path.basename(os.path.dirname(root))
        
        if directory == '.':
            continue
            
        if directory not in directories:
            if directory in ["๋ฐฑ์ค€", "ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค"]:
                content += "## ๐Ÿ“š {}\n".format(directory)
            else:
                content += "### ๐Ÿš€ {}\n".format(directory)
                content += "| ๋ฌธ์ œ๋ฒˆํ˜ธ | ๋งํฌ |\n"
                content += "| ----- | ----- |\n"
            directories.append(directory)

        for file in files:
            if category not in solveds:
                content += "|{}|[๋งํฌ]({})|\n".format(category, parse.quote(os.path.join(root, file)))
                solveds.append(category)
                print("category : " + category)

    with open("README.md", "w") as fd:
        fd.write(content)
        
if __name__ == "__main__":
    main()

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์— ์˜์กด์ ์ด๋‹ค.("๋ฐฑ์ค€", "ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค" ๋“ฑ ํด๋”๋ช… ํ•˜๋“œ์ฝ”๋”ฉใ…‹ใ…‹)

๋ฆฌ๋“œ๋ฏธ์˜ ๋ฐฑ์ค€/ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ๋ ˆ๋ฒจ๋ณ„ ํ‘ผ ๋ฌธ์ œ ๋ชฉ๋ก์„ ํ…Œ์ด๋ธ”๋กœ ๋ณด์—ฌ์ฃผ๋„๋ก ์„ธํŒ…ํ–ˆ๋‹ค.
๋‹ค์†Œ ๋ฐฐํฌ ์†๋„๊ฐ€ ๋Š๋ฆฐ ๊ฐ์€ ์žˆ์ง€๋งŒใ…Žใ…Ž;; ์ผ๋‹จ ๋Œ์•„๊ฐ€๋‹ˆ๊นŒ ๊ทธ๋Œ€๋กœ ๋‘๊ณ  ๋‚˜์ค‘์— ์ˆ˜์ •ํ•˜๋ ค ํ•œ๋‹ค.

์ž๋™ ์ƒ์„ฑ๋œ ์•„๋ฆ„๋‹ค์šด ๋ฆฌ๋“œ๋ฏธ ํ…Œ์ด๋ธ”!!๐Ÿฅบ

3) ์ฃผ์˜์‚ฌํ•ญ

ํ˜„์žฌ ๋ฆฌ๋“œ๋ฏธ๋Š” update.py ํŒŒ์ผ์„ ํ†ตํ•ด ๋งค๋ฒˆ ์žฌ์ƒ์„ฑ๋˜๊ณ  ์žˆ๋‹ค.
๋”ฐ๋ผ์„œ ๋ฆฌ๋“œ๋ฏธ ๋‚ด์šฉ์„ ์ง์ ‘ ์ˆ˜์ •ํ•˜๊ณ  ์‹ถ๋‹ค๋ฉด README.md ํŒŒ์ผ์ด ์•„๋‹Œ update.py ํŒŒ์ผ์„ ์ˆ˜์ •ํ•ด์•ผ ํ•œ๋‹ค!
์ด์  ์žŠ์ง€ ๋ง์ž!!!

์ฐธ๊ณ ์ž๋ฃŒ

Github Action์œผ๋กœ ์ž๋™์œผ๋กœ README.md์— ๋งํฌ ์ƒ์„ฑํ•˜๊ธฐ

profile
๐ŸŒฑ ํ•จ๊ป˜ ์ž๋ผ๋Š” ์ค‘์ž…๋‹ˆ๋‹ค ๐Ÿš€ rerub0831@gmail.com

7๊ฐœ์˜ ๋Œ“๊ธ€

comment-user-thumbnail
2023๋…„ 2์›” 2์ผ

๊ธ€ ์ž˜ ์ฝ์—ˆ์Šต๋‹ˆ๋‹ค !
ํ˜น์‹œ ์ €๋„ ํ…Œ์ด๋ธ” ๋ฐฉ์‹์œผ๋กœ ๋ฐฑ์ค€ ๋ฌธ์ œ๋ฅผ ์—…๋กœ๋“œํ•˜๊ณ  ์‹ถ์€๋ฐ ์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ํ•˜๋”๋ผ๋„ ์ œ ๊นƒํ—ˆ๋ธŒ ์ ‘๊ทผ ์š”์ฒญ์ด ์•ˆ๋œ๋‹ค๊ณ  ๋‚˜์˜ค๋Š”๋ฐ ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋Š”์ง€ ์—ฌ์ญค๋ณผ ์ˆ˜ ์žˆ์„๊นŒ์š” ?

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2023๋…„ 3์›” 21์ผ

๊ฟ€ํŒ์ด๋„ค์š”!!! ์ €๋„ ๊ธ€๋ณด๊ณ  ๋”ฐ๋ผํ–ˆ๋Š”๋ฐ ํ…Œ์ด๋ธ” ํ˜•์‹์œผ๋กœ ๋‚˜์˜ค์ง€๋„ ์•Š๊ณ  ์ž๋™ ์ปค๋ฐ‹์ด ๋˜๋ฉด [ffinguMac/BOJ] Run failed: Update readme - main (552e3a9) ์ด๋Ÿฐ ๋ฉ”์ผ ์•Œ๋žŒ์ด ์ž๊พธ ์˜ค๋„ค์š”...ใ… ใ…  ํ•œ๋ฒˆ ๋ด์ฃผ์‹ค์ˆ˜ ์žˆ๋‚˜์š”?? ์ œ ๊นƒ ๊ณ„์ •์€ ffinguMac์ž…๋‹ˆ๋‹ค!!

1๊ฐœ์˜ ๋‹ต๊ธ€
comment-user-thumbnail
2023๋…„ 5์›” 6์ผ

์•ˆ๋…•ํ•˜์„ธ์š” ์ข‹์€๊ธ€ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค
์„ ์ƒ๋‹˜ ๊ทธ๋Ÿฐ๋ฐ ์ €๋Š” ์™œ 3๋ฒˆํ•ญ๋ชฉ์ฒ˜๋Ÿผ '์ „์ฒด์ œ์ถœ ์—…๋กœ๋“œ' ๋ผ๋Š”๊ฒŒ ์—†๊ณ  ์ •๋ณด, ์–ธ์–ด ๋งŒ ์žˆ์„๊นŒ์š” ? ใ…œใ… 

๋‹ต๊ธ€ ๋‹ฌ๊ธฐ