Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🌎 Feature] github action을 ν™œμš©ν•œ κΈ€ 개수 μžλ™ UPDATE #209 #210

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions .github/workflows/auto-pr-for-count-files.yml

This file was deleted.

44 changes: 44 additions & 0 deletions .github/workflows/md-file-counter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 10000-bagger Auto Markdown File Count Workflow

on:
push:
branches:
- main
pull_request:
types:
- closed
branches:
- main

jobs:
build:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'

- name: count files
run: |
python3 -m counter

- name: Commit changes
run: |
git config --local user.email "dfghcvb11@naver.com"
git config --local user.name "binary-ho"
git add -u
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "10000-bagger auto md file counter"
fi


- name: Push changes
run: |
git push origin main
41 changes: 0 additions & 41 deletions .github/workflows/python-app.yml

This file was deleted.

7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.next
node_modules

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 자유 주제 μŠ€ν„°λ””
### 전체 아티클 갯수: 61개
### 전체 아티클 갯수: 96개

<br>

Expand Down
Empty file added counter/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions counter/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os

def count_md_files(directory):
md_count = 0
for root, dirs, files in os.walk(directory):
md_count += sum(1 for file in files if file.endswith('.md'))
return md_count


if __name__ == "__main__":
root = os.getcwd()
md_file_count = count_md_files(root) - 1 # README.md 파일 μ œμ™Έ
readme_path = os.path.join(root, 'README.md')

with open(readme_path, 'r', encoding='utf-8') as file:
readme_contents = file.readlines()

for i, line in enumerate(readme_contents):
if line.startswith("### 전체 아티클 갯수:"):
readme_contents[i] = f"### 전체 아티클 갯수: {md_file_count}개\n"
break

with open(readme_path, 'w', encoding='utf-8') as file:
file.writelines(readme_contents)

print(f"Updated the README.md with total article count: {md_file_count}")
95 changes: 0 additions & 95 deletions utils/count_files.py

This file was deleted.

Loading