-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from egg528/main
[🌎 Feature] github action을 활용한 글 개수 자동 UPDATE #209
- Loading branch information
Showing
8 changed files
with
78 additions
and
167 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
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 "[email protected]" | ||
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 |
This file was deleted.
Oops, something went wrong.
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
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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# 자유 주제 스터디 | ||
### 전체 아티클 갯수: 61개 | ||
### 전체 아티클 갯수: 96개 | ||
|
||
<br> | ||
|
||
|
Empty file.
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
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}") |
This file was deleted.
Oops, something went wrong.