Skip to content

Commit

Permalink
feat: support multi-platform posts to render at readme
Browse files Browse the repository at this point in the history
  • Loading branch information
baozouai committed May 13, 2023
0 parents commit f0f3988
Show file tree
Hide file tree
Showing 24 changed files with 4,362 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
@@ -0,0 +1,4 @@
dist/
lib/
node_modules/
jest.config.js
12 changes: 12 additions & 0 deletions .eslintrc.cjs
@@ -0,0 +1,12 @@
process.env.ESLINT_TSCONFIG = 'tsconfig.json'

module.exports = {
extends: '@antfu',
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/prefer-ts-expect-error': 'off',
'no-console': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-unsafe-member-access': 'off',
},
}
1 change: 1 addition & 0 deletions .gitattributes
@@ -0,0 +1 @@
dist/** -diff linguist-generated=true
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,97 @@
name: CI

on:
push:
branches:
- master

pull_request:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

- name: Lint
run: nr lint

typecheck:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

test:
runs-on: ${{ matrix.os }}

strategy:
matrix:
node: [16.x, 18.x]
os: [ubuntu-latest, windows-latest, macos-latest]
fail-fast: false

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node ${{ matrix.node }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
cache: pnpm

- name: Setup
run: npm i -g @antfu/ni

- name: Install
run: nci

# - name: Test
# run: nr test --run --coverage

- name: Build
run: nr build

# - name: Upload coverage report to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# files: coverage/lcov.info
# fail_ci_if_error: true
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,42 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- 'v*'

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install pnpm
uses: pnpm/action-setup@v2

- name: Set node
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: 'https://registry.npmjs.org'

- name: ChangeLog
run: npx changelogithub
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

# - name: Setup
# run: npm i -g @antfu/ni

# - name: Install
# run: nci

# - name: Release
# run: nr release
# env:
# NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
98 changes: 98 additions & 0 deletions .gitignore
@@ -0,0 +1,98 @@
# Dependency directory
node_modules

# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# OS metadata
.DS_Store
Thumbs.db

# Ignore built ts files
__tests__/runner/*
1 change: 1 addition & 0 deletions .nvmrc
@@ -0,0 +1 @@
16.14
3 changes: 3 additions & 0 deletions .prettierignore
@@ -0,0 +1,3 @@
dist/
lib/
node_modules/
10 changes: 10 additions & 0 deletions .prettierrc.json
@@ -0,0 +1,10 @@
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"arrowParens": "avoid"
}
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
@@ -0,0 +1 @@
* @actions/actions-runtime
22 changes: 22 additions & 0 deletions LICENSE
@@ -0,0 +1,22 @@

The MIT License (MIT)

Copyright (c) 2018 GitHub, Inc. and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
40 changes: 40 additions & 0 deletions README.md
@@ -0,0 +1,40 @@
# 在 README 中生成不同平台的最近文章,支持掘金、知乎、语雀、思否


## 使用方法

1.`README` 中任意位置添加标志位

```markdown
<!-- multi-platform-posts start -->
这里会插入生成的文章列表
<!-- multi-platform-posts end -->
```

2. 设置工作流

```yaml
jobs:
multi-platform-posts:
runs-on: ubuntu-latest
steps:
# 使用 actions/checkout 拉取仓库, see: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v3

# 使用 baozouai/multi-platform-posts-action 生成文章列表,
# see: https://github.com/baozouai/multi-platform-posts-action
- name: Append multi-platform-posts Posts List 📚
uses: baozouai/multi-platform-posts-action@main
with:
user_id: '4459274891717223' # add your userid
platform: juejin # juejin | zhihu | yuque | segmentfault
- run: |
git pull
- name: Push to GitHub
uses: EndBug/add-and-commit@v9
with:
branch: main
default_author: github_actions
message: juejin-posts # or yuque-posts; zhihu-posts; segmentfault-posts
```
22 changes: 22 additions & 0 deletions action.yml
@@ -0,0 +1,22 @@
# see: https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions
name: Render Multi-platform Posts in Readme
description: Render Multi-platform Posts in Readme

# 定义当前步骤参数
inputs:
user_id:
description: 用户 ID
required: true
default: ''
platform:
description: 平台,目前支持掘金、知乎、语雀、思否
required: true
default: ''

# 向下一个步骤输出参数
# outputs:
# time: # output will be available to future steps
# description: 'The message to output'
runs:
using: node16
main: lib/index.js
9 changes: 9 additions & 0 deletions jest.config.js
@@ -0,0 +1,9 @@
module.exports = {
clearMocks: true,
moduleFileExtensions: ['js', 'ts'],
testMatch: ['**/*.test.ts'],
transform: {
'^.+\\.ts$': 'ts-jest'
},
verbose: true
}

0 comments on commit f0f3988

Please sign in to comment.