Skip to content

Commit ae712ac

Browse files
Troy's edits Merge pull request #2 from tmr08c/tr-suggestion-for-xpost-article
Minor edit suggestions for crosspost article.
2 parents 7a973e9 + c7eeba8 commit ae712ac

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

content/articles/using-github-to-crosspost-to-dev-to.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Want to crosspost to dev.to? There's a GitHub action for that.
33
published: false
4-
description: When I create a new markdown article, I don't want to have copy and paste that markdown to multiple other blog sites. So, why not let an octocat handle this work for me with a GitHub action?
4+
description: When I create a new markdown article, I don't want to have to copy and paste that markdown to multiple other blog sites. So, why not let an Octokit handle this work for me with a GitHub action?
55
tags: typescript, github, opensource, actions
66
cover_image: https://cdn.nanalyze.com/uploads/2018/07/automation-rpa-teaser.jpg
77
---
@@ -25,7 +25,7 @@ The first order of business is to find out if your last commit contains articles
2525

2626
<br>
2727

28-
In order to do so, we first require 2 inputs from the GitHub workflow: github-token & content-dir. These 2 arguments will be retrieved using the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package. The `github-token` argument will be used to initiate an [Octokit Rest client](https://octokit.github.io/rest.js/v18/) using the [@actions/github](https://github.com/actions/toolkit/tree/main/packages/github) package. We can use this instance to request the commit data. Once we have the response, all we have to do is iterate over the list of files and see if the filename match a given content directory (from the `content-dir` argument).
28+
In order to do so, we first require two inputs from the GitHub workflow: `github-token` & `content-dir`. These two arguments will be retrieved using the [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) package. The `github-token` argument will be used to initiate an [Octokit Rest client](https://octokit.github.io/rest.js/v18/) using the [@actions/github](https://github.com/actions/toolkit/tree/main/packages/github) package. We can use this instance to request the commit data. Once we have the response, all we have to do is iterate over the list of files and see if the filename match a given content directory (from the `content-dir` argument).
2929

3030
```typescript
3131
import * as core from '@actions/core';
@@ -43,11 +43,10 @@ export const getFiles = async (): Promise<string[]> => {
4343
.map((file: any) => file.filename)
4444
.filter((filename: string) => filename.includes(core.getInput('content-dir')));
4545
};
46-
4746
```
4847

4948
If this code finds markdown files, we will cycle through each file, sending it into a `publish` function.
50-
We will use node's file system [`readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) function to read the file into memory. Then, using the [`@github-docs/frontmatter`](https://github.com/docs/frontmatter) package to parse the markdown so we can checkout the [frontmatter](https://jekyllrb.com/docs/front-matter/) which is just the "data" at the top of markdown files.
49+
We will use Node's file system [`readFileSync`](https://nodejs.org/api/fs.html#fs_fs_readfilesync_path_options) function to read the file into memory. Then, use the [`@github-docs/frontmatter`](https://github.com/docs/frontmatter) package to parse the markdown so we can checkout the [frontmatter](https://jekyllrb.com/docs/front-matter/) which is just the "data" at the top of markdown files.
5150

5251
<br>
5352

@@ -170,7 +169,7 @@ Super simple.
170169
171170
<br>
172171
173-
Next step will be to run the crosspost-markdown action and pass in the necessary arguments (content-dir & dev-to-token). These can be set in the [secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets) section of your repo's settings.
172+
Next step will be to run the `crosspost-markdown` action and pass in the necessary arguments (`content-dir` and `dev-to-token`). These can be set in the [secrets](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets) section of your repo's settings.
174173

175174
```yaml
176175
jobs:

0 commit comments

Comments
 (0)