Skip to content

Commit

Permalink
Merge pull request #4 from web333wiki/bear-add-ci
Browse files Browse the repository at this point in the history
Add CI to check cards
  • Loading branch information
boundless-forest authored Nov 28, 2024
2 parents b73d6dd + 4222a5a commit 649753c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 2 deletions.
26 changes: 26 additions & 0 deletions .github/scripts/check-cards.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
import sys

def check_cards():
valid_tags = ['#show-card', '#awesome-card', '#explain-card', '#grant-card']
cards_dir = 'cards'

for root, _, files in os.walk(cards_dir):
for file in files:
if file.endswith('.md'):
with open(os.path.join(root, file), 'r') as f:
lines = f.readlines()
first_line = lines[0].strip()
if file == 'Web3 Wiki.md':
if not all(tag in first_line for tag in valid_tags):
print(f"Error: {file} does not contain all valid tags in the first line.")
sys.exit(1)
else:
tags_in_file = [line.strip() for line in lines if line.strip() in valid_tags]
if len(tags_in_file) != 1:
print(f"Error: {file} should contain exactly one valid tag.")
sys.exit(1)
print("All cards are valid.")

if __name__ == "__main__":
check_cards()
23 changes: 23 additions & 0 deletions .github/workflows/check-cards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Check Cards

on: [push, pull_request]

jobs:
check-cards:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

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

- name: Install dependencies
run: |
python -m pip install --upgrade pip
- name: Run card check script
run: python .github/scripts/check-cards.py
1 change: 0 additions & 1 deletion cards/Diem.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#show-card

>[!todo]
Expand Down
2 changes: 1 addition & 1 deletion cards/Template show-card.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#show-card
#show-card

## Introduction

Expand Down

0 comments on commit 649753c

Please sign in to comment.