Skip to content

Commit df55ed5

Browse files
authored
Update 2.yml
1 parent 59e17e6 commit df55ed5

1 file changed

Lines changed: 0 additions & 9 deletions

File tree

.github/workflows/2.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on:
55
branches:
66
- main
77
paths:
8-
# فقط زمانی اجرا شو که فایل‌های منبع تغییر کنند، نه فایل‌های checksum
98
- 'files/**'
109
- '!.github/**'
1110
- '!files/**/*.sha256'
@@ -14,7 +13,6 @@ on:
1413

1514
jobs:
1615
generate-checksums:
17-
# به این جاب اجازه نوشتن در ریپازیتوری را می‌دهد
1816
permissions:
1917
contents: write
2018

@@ -35,7 +33,6 @@ import sys
3533

3634
def manage_checksums(root_dir):
3735
source_files = set()
38-
# ابتدا تمام فایل‌های منبع (غیر از checksum) را پیدا می‌کنیم
3936
for dirpath, _, filenames in os.walk(root_dir):
4037
if ".git" in dirpath:
4138
continue
@@ -44,31 +41,26 @@ def manage_checksums(root_dir):
4441
source_files.add(os.path.join(dirpath, filename))
4542

4643
existing_checksum_files = set()
47-
# سپس تمام فایل‌های checksum موجود را لیست می‌کنیم
4844
for dirpath, _, filenames in os.walk(root_dir):
4945
if ".git" in dirpath:
5046
continue
5147
for filename in filenames:
5248
if filename.endswith('.sha256'):
5349
existing_checksum_files.add(os.path.join(dirpath, filename))
5450

55-
# برای تمام فایل‌های منبع، checksum تولید یا به‌روزرسانی می‌کنیم
5651
for file_path in source_files:
5752
sha256_hash = hashlib.sha256()
5853
with open(file_path, "rb") as f:
59-
# خواندن فایل به صورت تکه‌تکه برای مدیریت فایل‌های حجیم
6054
for byte_block in iter(lambda: f.read(4096), b""):
6155
sha256_hash.update(byte_block)
6256

6357
checksum_file_path = f"{file_path}.sha256"
6458
base_filename = os.path.basename(file_path)
6559

66-
# نوشتن هش در فایل مجزا با فرمت استاندارد
6760
with open(checksum_file_path, "w", encoding="utf-8") as f:
6861
f.write(f"{sha256_hash.hexdigest()} *{base_filename}\n")
6962
print(f"Generated/Updated checksum for {file_path}")
7063

71-
# فایل‌های checksum قدیمی (که فایل منبع آن‌ها حذف شده) را پیدا و حذف می‌کنیم
7264
required_checksum_files = {f"{f}.sha256" for f in source_files}
7365
stale_files = existing_checksum_files - required_checksum_files
7466

@@ -96,7 +88,6 @@ EOF
9688
uses: stefanzweifel/git-auto-commit-action@v5
9789
with:
9890
commit_message: "ci: Update individual file checksums"
99-
# الگوی فایل برای کامیت کردن تمام فایل‌های .sha256 در پوشه files
10091
file_pattern: "files/**/*.sha256"
10192
commit_user_name: "GitHub Actions Bot"
10293
commit_user_email: "github-actions[bot]@users.noreply.github.com"

0 commit comments

Comments
 (0)