Skip to content

Commit

Permalink
initialize topics-index
Browse files Browse the repository at this point in the history
Intialize the index with:
- current index
- script to build the index
- github action to weekly check for new optech topics
- updated README
  • Loading branch information
kouloumos committed Nov 22, 2024
1 parent 847cd9b commit 83853e3
Show file tree
Hide file tree
Showing 6 changed files with 2,596 additions and 2 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/update-topics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Update Topics Index (Weekly)

on:
schedule:
- cron: '0 0 * * 0' # Runs at 00:00 UTC every Sunday
workflow_dispatch: # Allows manual triggering
push:
branches:
- 'test/*' # Runs on any branch under test/

# Add explicit permissions for the GITHUB_TOKEN
permissions:
contents: write # Allows pushing to the repository

jobs:
update-topics:
runs-on: ubuntu-latest

# Add environment variables to control behavior
env:
IS_TEST: ${{ startsWith(github.ref, 'refs/heads/test/') }}

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

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: pip install -r scripts/requirements.txt

- name: Build Index
run: python scripts/build_index.py

- name: Check for changes
id: changes
run: |
git diff --quiet || echo "changes=true" >> $GITHUB_OUTPUT
- name: Configure Git
if: steps.changes.outputs.changes == 'true'
run: |
git config user.name "GitHub Actions Bot"
git config user.email "[email protected]"
# Add debug information in test mode
- name: Debug Info (Test Mode)
if: env.IS_TEST == 'true'
run: |
echo "Changes detected: ${{ steps.changes.outputs.changes }}"
git diff --stat
git status
- name: Commit and push if there are changes
if: steps.changes.outputs.changes == 'true'
run: |
git add topics.json TOPICS.md
# Add [TEST] prefix to commit message on test branches
if [[ "${{ env.IS_TEST }}" == "true" ]]; then
git commit -m "[TEST] Auto-update topics index"
else
git commit -m "Auto-update topics index"
fi
git push
62 changes: 60 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,60 @@
# topics-index
A list of Bitcoin topics
# Bitcoin Topics Index

An extensive index of Bitcoin-related topics, combining and enhancing the established [Bitcoin Optech Topics](https://bitcoinops.org/en/topics/) with additional relevant entries.

See [TOPICS.md](TOPICS.md) for the categorized index or [topics.json](topics.json) for the machine-readable format.

## Repository Structure

```
.
├── topics/ # Bitcoin topics
│ ├── topic1.yaml
│ ├── topic2.yaml
│ └── ...
├── scripts/ # Build and maintenance scripts
│ └── build_index.py
├── topics.json # Machine-readable index
├── TOPICS.md # Generated documentation
└── README.md
```

## Topics Format

Each topic is defined in YAML format with the following structure:

```yaml
title: "Topic Title" # Display name of the topic
slug: "topic-slug" # URL-friendly identifier
categories: # List of categories this topic belongs to
- "Category 1"
- "Category 2"
aliases: # Optional: Alternative names for the topic
- "Alternative Name"
- "Another Name"
excerpt: "A comprehensive description of the topic."
```
## Usage
### Building the Index
To build the combined index and documentation:
```bash
python scripts/build_index.py
```

This will:

1. Fetch the latest topics from Bitcoin Optech's [/topics.json](https://bitcoinops.org/topics.json).
2. Combine them with additional topics from the `topics/` directory
3. Automatically generate miscellaneous topics for each category to support uncategorized content
4. Generate `topics.json` with the complete topics data
5. Create `TOPICS.md` with categorized listings

### Adding Topics

1. Create a new YAML file in the `topics/` directory
2. Follow the topics format described above
3. Run the build script to update the index
Loading

0 comments on commit 83853e3

Please sign in to comment.