Compare commits
24 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
16430922c4 | ||
|
20b7de127d | ||
|
9def6961a9 | ||
|
f846c5ee47 | ||
|
8133f1f32e | ||
|
19e564c928 | ||
|
9c0b62271d | ||
|
7ceb9cb783 | ||
|
cee1906a39 | ||
|
0211f01bfb | ||
|
970d603c2e | ||
|
e558e07817 | ||
|
202d6fe6c3 | ||
|
ab02c0d880 | ||
|
110a667b31 | ||
|
fc187df45e | ||
|
389dc4441f | ||
|
bbc8ec9ca5 | ||
|
10151792e7 | ||
|
012928bcda | ||
|
fe15d9358c | ||
|
5753aefaa3 | ||
|
fb228f6b20 | ||
|
3ad155575d |
32
CHANGELOG.md
32
CHANGELOG.md
@@ -1,36 +1,36 @@
|
||||
## <small>1.0.31 (2021-01-21)</small>
|
||||
## <small>1.0.37 (2021-06-23)</small>
|
||||
|
||||
* feat: added user/email input for commiting ([58a7dc1](https://github.com/simonecorsi/mawesome/commit/58a7dc1))
|
||||
* build(deps): bump glob-parent from 5.1.1 to 5.1.2 ([e558e07](https://github.com/simonecorsi/mawesome/commit/e558e07))
|
||||
* build(deps): bump hosted-git-info from 2.8.8 to 2.8.9 ([110a667](https://github.com/simonecorsi/mawesome/commit/110a667))
|
||||
* build(deps): bump normalize-url from 4.5.0 to 4.5.1 ([202d6fe](https://github.com/simonecorsi/mawesome/commit/202d6fe))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.30 (2021-01-16)</small>
|
||||
## <small>1.0.36 (2021-06-23)</small>
|
||||
|
||||
* chore(release): v1.0.30 ([a5f15da](https://github.com/simonecorsi/mawesome/commit/a5f15da))
|
||||
* fix: removed push ([7f42ca0](https://github.com/simonecorsi/mawesome/commit/7f42ca0))
|
||||
* chore(release): v1.0.36 ([9c0b622](https://github.com/simonecorsi/mawesome/commit/9c0b622))
|
||||
* feat: saving json data for future use ([7ceb9cb](https://github.com/simonecorsi/mawesome/commit/7ceb9cb))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.29 (2021-01-16)</small>
|
||||
## <small>1.0.35 (2021-06-22)</small>
|
||||
|
||||
* chore(release): v1.0.29 ([874894b](https://github.com/simonecorsi/mawesome/commit/874894b))
|
||||
* ci: on pull_request hook ([748c821](https://github.com/simonecorsi/mawesome/commit/748c821))
|
||||
* ci: test on push ([226c942](https://github.com/simonecorsi/mawesome/commit/226c942))
|
||||
* feat: added test workflow for pr ([1bd01f6](https://github.com/simonecorsi/mawesome/commit/1bd01f6))
|
||||
* chore(release): v1.0.35 ([cee1906](https://github.com/simonecorsi/mawesome/commit/cee1906))
|
||||
* build(deps): bump set-getter from 0.1.0 to 0.1.1 ([970d603](https://github.com/simonecorsi/mawesome/commit/970d603))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.28 (2021-01-16)</small>
|
||||
## <small>1.0.34 (2021-05-19)</small>
|
||||
|
||||
* chore(release): v1.0.28 ([c805822](https://github.com/simonecorsi/mawesome/commit/c805822))
|
||||
* tests: added tests ([b8890fc](https://github.com/simonecorsi/mawesome/commit/b8890fc))
|
||||
* chore(release): v1.0.34 ([ab02c0d](https://github.com/simonecorsi/mawesome/commit/ab02c0d))
|
||||
|
||||
|
||||
|
||||
## <small>1.0.27 (2021-01-16)</small>
|
||||
## <small>1.0.33 (2021-05-19)</small>
|
||||
|
||||
* chore(release): v1.0.27 ([bf07858](https://github.com/simonecorsi/mawesome/commit/bf07858))
|
||||
* docs: typo ([46172a5](https://github.com/simonecorsi/mawesome/commit/46172a5))
|
||||
* chore(release): v1.0.33 ([fc187df](https://github.com/simonecorsi/mawesome/commit/fc187df))
|
||||
* build(deps): bump handlebars from 4.7.6 to 4.7.7 ([012928b](https://github.com/simonecorsi/mawesome/commit/012928b))
|
||||
* build(deps): bump lodash from 4.17.20 to 4.17.21 ([1015179](https://github.com/simonecorsi/mawesome/commit/1015179))
|
||||
|
||||
|
||||
|
||||
|
42
README.md
42
README.md
@@ -1,20 +1,41 @@
|
||||
# My Awesome list
|
||||
# My Awesome List
|
||||
|
||||
This action query the github api to get starred list of the user and then generates a list ordered by languages.
|
||||
This action query the github api to get starred list of the user and then generates a list ordered by languages.
|
||||
|
||||
You can see an example of the output at my own [simonecorsi/awesome](https://github.com/simonecorsi/awesome)
|
||||
|
||||
## Setup
|
||||
## Table of Contents
|
||||
|
||||
To use this action you have to create your own repository (eg: `yourname/awesome`), then create a new empty action in it and then use the [example workflow](#example-workflow) below as a starting point.
|
||||
<!-- toc -->
|
||||
|
||||
## Inputs
|
||||
- [Table of Contents](#table-of-contents)
|
||||
- [Documentation](#documentation)
|
||||
- [Requirements](#requirements)
|
||||
- [Configuration](#configuration)
|
||||
- [`api-token`](#api-token)
|
||||
- [Example workflow](#example-workflow)
|
||||
|
||||
### `github-token`
|
||||
<!-- tocstop -->
|
||||
|
||||
The github workflow token is mandatory
|
||||
## Documentation
|
||||
|
||||
### `api-token`
|
||||
### Requirements
|
||||
|
||||
- An empty repository
|
||||
- A personal github api key
|
||||
|
||||
### Configuration
|
||||
|
||||
The service can be configured setting the appropriate environment variables or writing an `.env` file.
|
||||
|
||||
| Variable | Description | Default |
|
||||
| -------------- | ------------------------------------------- | -------------------------------- |
|
||||
| `api-token` | Personal github api token. | `${{ secrets.API_TOKEN }}` |
|
||||
| `github-token` | Action Token | `${{ secrets.GITHUB_TOKEN }}` |
|
||||
| `github-name` | Name used for the commit, default to action | Github Action |
|
||||
| `github-email` | email used for commit, default to action | actions@users.noreply.github.com |
|
||||
|
||||
#### `api-token`
|
||||
|
||||
The Personal API Access Token is mandatory to fetch stars from the API without incurring in Rate Limits.
|
||||
|
||||
@@ -36,8 +57,11 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Awesome generator
|
||||
uses: simonecorsi/mawesome@lastest
|
||||
uses: simonecorsi/mawesome@latest
|
||||
with:
|
||||
api-token: ${{ secrets.API_TOKEN }}
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github-email: ${{ secrets.USER_EMAIL }}
|
||||
github-name: ${{ github.repository_owner }}
|
||||
|
||||
```
|
||||
|
@@ -10,6 +10,10 @@ inputs:
|
||||
api-token:
|
||||
description: 'Personal API Token'
|
||||
required: true
|
||||
github-name:
|
||||
description: 'Name shown in the commit'
|
||||
github-email:
|
||||
description: 'Email shown in the commit'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'index.js'
|
||||
|
29
index.js
29
index.js
@@ -21361,7 +21361,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
var _a;
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.pushNewFile = exports.OUTPUT_FILENAME = exports.generateMd = exports.paginate = exports.API_STARRED_URL = exports.REPO_USERNAME = exports.apiGetStar = exports.renderer = exports.isLastPage = exports.wait = void 0;
|
||||
exports.pushNewFiles = exports.MARKDOWN_FILENAME = exports.generateMd = exports.paginate = exports.API_STARRED_URL = exports.REPO_USERNAME = exports.apiGetStar = exports.renderer = exports.isLastPage = exports.wait = void 0;
|
||||
const ejs_1 = __importDefault(__nccwpck_require__(8431));
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const remark_1 = __importDefault(__nccwpck_require__(2081));
|
||||
@@ -21433,17 +21433,21 @@ function generateMd(data) {
|
||||
});
|
||||
}
|
||||
exports.generateMd = generateMd;
|
||||
exports.OUTPUT_FILENAME = core.getInput('output-filename') || 'README.md';
|
||||
function pushNewFile(markdown) {
|
||||
exports.MARKDOWN_FILENAME = core.getInput('output-filename') || 'README.md';
|
||||
function pushNewFiles(files = []) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield fsp.writeFile(exports.OUTPUT_FILENAME, markdown);
|
||||
if (!files.length)
|
||||
return;
|
||||
yield git_1.default.pull();
|
||||
yield git_1.default.add(exports.OUTPUT_FILENAME);
|
||||
yield git_1.default.commit(`chore(${exports.OUTPUT_FILENAME}): updated ${exports.OUTPUT_FILENAME}`);
|
||||
yield Promise.all(files.map(({ filename, data }) => __awaiter(this, void 0, void 0, function* () {
|
||||
yield fsp.writeFile(filename, data);
|
||||
yield git_1.default.add(filename);
|
||||
yield git_1.default.commit(`chore(${filename}): updated ${filename}`);
|
||||
})));
|
||||
yield git_1.default.push();
|
||||
});
|
||||
}
|
||||
exports.pushNewFile = pushNewFile;
|
||||
exports.pushNewFiles = pushNewFiles;
|
||||
|
||||
|
||||
/***/ }),
|
||||
@@ -21511,7 +21515,16 @@ function main() {
|
||||
updatedAt: Date.now(),
|
||||
});
|
||||
const markdown = yield helpers_1.generateMd(rendered);
|
||||
yield helpers_1.pushNewFile(markdown);
|
||||
yield helpers_1.pushNewFiles([
|
||||
{
|
||||
filename: helpers_1.MARKDOWN_FILENAME,
|
||||
data: markdown,
|
||||
},
|
||||
{
|
||||
filename: 'data.json',
|
||||
data: JSON.stringify(sortedByLanguages, null, 2),
|
||||
},
|
||||
]);
|
||||
});
|
||||
}
|
||||
exports.main = main;
|
||||
|
967
package-lock.json
generated
967
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mawesome",
|
||||
"version": "1.0.31",
|
||||
"version": "1.0.37",
|
||||
"description": "Generate awesome list from user starred repositories",
|
||||
"main": "index.js",
|
||||
"author": "Simone Corsi<simonecorsi.dev@gmail.com>",
|
||||
@@ -12,7 +12,7 @@
|
||||
"style:prettier": "prettier \"src/**/*.ts\" --list-different --write",
|
||||
"build": "./node_modules/.bin/ncc build src/index.ts -o ./",
|
||||
"dev": "ts-node-dev src/index.ts",
|
||||
"prerelease": "npm run build && "
|
||||
"prerelease": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
"github",
|
||||
@@ -37,7 +37,6 @@
|
||||
"@vercel/ncc": "^0.26.2",
|
||||
"ava": "^3.8.2",
|
||||
"benchmark": "^2.1.4",
|
||||
"conventional-gitlab-releaser": "^4.0.1",
|
||||
"cz-conventional-changelog": "^3.2.0",
|
||||
"eslint": "^7.17.0",
|
||||
"eslint-config-prettier": "^7.1.0",
|
||||
|
@@ -77,12 +77,26 @@ export function generateMd(data: string): Promise<string> {
|
||||
});
|
||||
}
|
||||
|
||||
export const OUTPUT_FILENAME: string =
|
||||
export const MARKDOWN_FILENAME: string =
|
||||
core.getInput('output-filename') || 'README.md';
|
||||
export async function pushNewFile(markdown: string): Promise<any> {
|
||||
await fsp.writeFile(OUTPUT_FILENAME, markdown);
|
||||
|
||||
type File = {
|
||||
filename: string;
|
||||
data: string;
|
||||
};
|
||||
|
||||
export async function pushNewFiles(files: File[] = []): Promise<any> {
|
||||
if (!files.length) return;
|
||||
|
||||
await git.pull();
|
||||
await git.add(OUTPUT_FILENAME);
|
||||
await git.commit(`chore(${OUTPUT_FILENAME}): updated ${OUTPUT_FILENAME}`);
|
||||
|
||||
await Promise.all(
|
||||
files.map(async ({ filename, data }) => {
|
||||
await fsp.writeFile(filename, data);
|
||||
await git.add(filename);
|
||||
await git.commit(`chore(${filename}): updated ${filename}`);
|
||||
})
|
||||
);
|
||||
|
||||
await git.push();
|
||||
}
|
||||
|
15
src/index.ts
15
src/index.ts
@@ -1,11 +1,13 @@
|
||||
import * as core from '@actions/core';
|
||||
import { data } from 'remark';
|
||||
|
||||
import {
|
||||
renderer,
|
||||
paginate,
|
||||
REPO_USERNAME,
|
||||
generateMd,
|
||||
pushNewFile,
|
||||
pushNewFiles,
|
||||
MARKDOWN_FILENAME,
|
||||
} from './helpers';
|
||||
|
||||
import type { SortedLanguageList, Stars, Star } from './types';
|
||||
@@ -41,7 +43,16 @@ export async function main(): Promise<any> {
|
||||
|
||||
const markdown: string = await generateMd(rendered);
|
||||
|
||||
await pushNewFile(markdown);
|
||||
await pushNewFiles([
|
||||
{
|
||||
filename: MARKDOWN_FILENAME,
|
||||
data: markdown,
|
||||
},
|
||||
{
|
||||
filename: 'data.json',
|
||||
data: JSON.stringify(sortedByLanguages, null, 2),
|
||||
},
|
||||
]);
|
||||
}
|
||||
|
||||
export async function run(): Promise<any> {
|
||||
|
@@ -38,7 +38,7 @@ import {
|
||||
apiGetStar,
|
||||
paginate,
|
||||
generateMd,
|
||||
pushNewFile,
|
||||
pushNewFiles,
|
||||
} from '../src/helpers';
|
||||
|
||||
test('wait should wait', async (t) => {
|
||||
@@ -97,7 +97,7 @@ test('generateMd should create TOC', async (t) => {
|
||||
});
|
||||
|
||||
test('should push', async (t) => {
|
||||
await pushNewFile('# title');
|
||||
await pushNewFiles([{filename: "README.md", data: '# title'}]);
|
||||
t.true(writeFile.calledWith('README.md', '# title'));
|
||||
t.true(pull.called);
|
||||
t.true(add.calledWith('README.md'));
|
||||
|
Reference in New Issue
Block a user