Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/trevorwslee/readme_to_devto
https://github.com/trevorwslee/readme_to_devto
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/trevorwslee/readme_to_devto
- Owner: trevorwslee
- Created: 2024-04-05T13:21:38.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-05-14T15:40:32.000Z (8 months ago)
- Last Synced: 2024-05-15T03:08:17.623Z (8 months ago)
- Size: 241 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
---
title: GitHub Repository README to DEV Community Post
description: Setup GitHub repo for automatically posting README to DEV Community
tags: 'github, readme, devto'
cover_image: ./assets/cat.jpg
published: true
id: 1812457
date: '2024-04-06T02:03:37Z'
---# GitHub Repository README to DEV Community Post
The enabler of the capability is a GitHub Action workflow contributed by the [publish-devto](https://github.com/sinedied/publish-devto) project
Hence, the picture
![cat.jpg](./assets/cat.jpg)
which is the sample that comes with the `publish-devto` project.
Here I will simply show how I setup GitHub repo for automatically posting README (`README.md`) to DEV Community (`dev.to`).
## On Dev Community Side
As expected, you will need some "access token" from `dev.to` for the workflow to work.
Indeed, you need to get an API token from `dev.to` -- `Settings` -> `Extension` -> `DEV Community API Keys`
![dev_api_key.png](assets/dev_api_key.png)
## On GitHub Side
GitHub also requires some [repository] settings for security measures.
Firstly, grant "read and write permissions" to "Workflow" -- `Settings` -> `Actions | General` -> `Workflow permissions` set to `Read and write permissions`
![rw_permit.png](assets/rw_permit.png)
Secondly, setup `DEVTO_TOKEN` secret (the API token you acquired in previous step) -- `Secret and variables | Actions` new `Repository secrets`
![set_secret.png](assets/set_secret.png)
***It appears that the repository needs be a public one.*** Otherwise, `dev.to` will fail to acquire the images.
## On Repo Source Side
Firstly, you will need `.github/workflows/publish.yml` that you can download [here](https://github.com/trevorwslee/readme_to_devto/blob/main/.github/workflows/publish.yml), which is one that I tailored from the one that comes with the `publish-devto` project
And ***importantly***, make sure that the `branch` specified in `publish.yml` is indeed the actual branch you want the action be triggered on
```
...
name: publish
on:
push:
branches: [main]
pull_request:
branches: [main]
...
# (Optional) The git branch to use. Default is 'main'.
branch: main
...
```Secondly, your `README.md` will need to have "headers" (starting from 1st line) like
```
---
title: GitHub Repository README to DEV Community Post
description: Setup GitHub repo for automatically posting README to DEV Community
tags: 'github, readme, devto'
cover_image: ./assets/cat.jpg
published: false
---
```Notes on the *headers*:
- `title` should be set correctly the first time, and should not be changed (unless you want to start a new post)
- `description` is optional (i.e can be missing)
- `tags` is optional, which is a list of comma-delimited single-words
- `cover_image` is optional
- `published` should be `false` until you want to publish the post
- the first successful trigger of the `publish` workflow, `id` will be added automatically (`README.md` modified in the repo, and need be pulled)
without the `id`, post will be treated as a new post## Commit Repo
That is it!
Commit and push the changes to GitHub, you should see the running of the workflow `publish`.
![workflow.png](assets/workflow.png)
If the workflow is successful, a new draft post will be created on Dev Community (`dev.to`)
***Be reminded that the first time successful running of the workflow, `id` will be automatically added to the "headers" of `README.md`.*** Pull for the addition.
***Hope this helps!***
# Enjoy!
> Peace be with you!
> May God bless you!
> Jesus loves you!
> Amazing Grace!