Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/calvinmclean/article-sync
synchronize markdown files with dev.to articles
https://github.com/calvinmclean/article-sync
Last synced: 21 days ago
JSON representation
synchronize markdown files with dev.to articles
- Host: GitHub
- URL: https://github.com/calvinmclean/article-sync
- Owner: calvinmclean
- License: apache-2.0
- Created: 2023-10-28T19:34:43.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-19T02:16:24.000Z (about 1 year ago)
- Last Synced: 2024-10-26T20:52:18.283Z (2 months ago)
- Language: Go
- Size: 97.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Article Sync
Manage your articles using git. Synchronize markdown files from a git repository to [dev.to](https://dev.to).
## Directory Structure
This relies on having a directory structure where each article/post consists of a directory with `article.md` and `article.json`:
```
articles/
└── test-article
├── article.json
└── article.md
```- `article.md`: this is the markdown contents of the post
- `article.json`: this contains some extra details about the post like the title and ID:
```json
{
"title": "My New Article",
"description": "this article is a test"
}
```Once an article is posted, the ID and slug are saved to the `article.json` file:
```json
{
"id": 1234,
"slug": "my-new-article-1234",
"title": "My New Article",
"description": "this article is a test"
}
```## GitHub Action Usage
When opening a PR, comment a summary of changes
```yaml
name: Synchronization summary
on:
pull_request:
branches:
- main
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: calvinmclean/[email protected]
with:
type: summary
api_key: ${{ secrets.DEV_TO_API_KEY }}
```After pushing to main, synchronize with dev.to and make a commit with new IDs if articles are created
```yaml
name: Synchronize and commit
on:
push:
branches:
- main
jobs:
commit_file:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: calvinmclean/[email protected]
with:
type: synchronize
api_key: ${{ secrets.DEV_TO_API_KEY }}
```This works declaratively by parsing each article and:
- If it does not have an ID, create a new article and save ID
- If it does have an ID:
- Compare to existing contents fetched by ID
- Update if changed, otherwise leave alone## Import Existing Articles
Simply run the CLI with `--init` flag to initialize a directory structure from existing articles.
Directory names use the article slug, but can be renamed without affecting the program.```shell
go run -mod=mod github.com/calvinmclean/article-sync@latest \
--api-key $API_KEY \
--init
```## Roadmap
- Allow naming files other than `article.md` or `article.json`