26 Commits

Author SHA1 Message Date
Conventional Changelog Action
16430922c4 chore(release): v1.0.37 2021-06-23 22:09:38 +00:00
Simone Corsi
20b7de127d Merge pull request #7 from simonecorsi/dependabot/npm_and_yarn/hosted-git-info-2.8.9
build(deps): bump hosted-git-info from 2.8.8 to 2.8.9
2021-06-24 00:09:33 +02:00
Simone Corsi
9def6961a9 Merge pull request #9 from simonecorsi/dependabot/npm_and_yarn/normalize-url-4.5.1
build(deps): bump normalize-url from 4.5.0 to 4.5.1
2021-06-24 00:09:23 +02:00
Simone Corsi
f846c5ee47 Merge pull request #10 from simonecorsi/dependabot/npm_and_yarn/glob-parent-5.1.2
build(deps): bump glob-parent from 5.1.1 to 5.1.2
2021-06-24 00:09:00 +02:00
Simone Corsi
8133f1f32e Merge branch 'main' into dependabot/npm_and_yarn/normalize-url-4.5.1 2021-06-24 00:08:00 +02:00
Simone Corsi
19e564c928 Merge branch 'main' into dependabot/npm_and_yarn/glob-parent-5.1.2 2021-06-24 00:07:19 +02:00
Conventional Changelog Action
9c0b62271d chore(release): v1.0.36 2021-06-23 22:05:32 +00:00
GitHub Actions
7ceb9cb783 feat: saving json data for future use 2021-06-24 00:04:22 +02:00
Conventional Changelog Action
cee1906a39 chore(release): v1.0.35 2021-06-22 13:35:23 +00:00
Simone Corsi
0211f01bfb Merge pull request #11 from simonecorsi/dependabot/npm_and_yarn/set-getter-0.1.1
build(deps): bump set-getter from 0.1.0 to 0.1.1
2021-06-22 15:34:31 +02:00
dependabot[bot]
970d603c2e build(deps): bump set-getter from 0.1.0 to 0.1.1
Bumps [set-getter](https://github.com/doowb/set-getter) from 0.1.0 to 0.1.1.
- [Release notes](https://github.com/doowb/set-getter/releases)
- [Commits](https://github.com/doowb/set-getter/commits/0.1.1)

---
updated-dependencies:
- dependency-name: set-getter
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-21 21:38:21 +00:00
dependabot[bot]
e558e07817 build(deps): bump glob-parent from 5.1.1 to 5.1.2
Bumps [glob-parent](https://github.com/gulpjs/glob-parent) from 5.1.1 to 5.1.2.
- [Release notes](https://github.com/gulpjs/glob-parent/releases)
- [Changelog](https://github.com/gulpjs/glob-parent/blob/main/CHANGELOG.md)
- [Commits](https://github.com/gulpjs/glob-parent/compare/v5.1.1...v5.1.2)

---
updated-dependencies:
- dependency-name: glob-parent
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-12 15:27:03 +00:00
dependabot[bot]
202d6fe6c3 build(deps): bump normalize-url from 4.5.0 to 4.5.1
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-06-12 03:41:41 +00:00
Conventional Changelog Action
ab02c0d880 chore(release): v1.0.34 2021-05-19 09:24:47 +00:00
dependabot[bot]
110a667b31 build(deps): bump hosted-git-info from 2.8.8 to 2.8.9
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-19 09:24:36 +00:00
Conventional Changelog Action
fc187df45e chore(release): v1.0.33 2021-05-19 09:24:33 +00:00
Simone Corsi
389dc4441f Merge pull request #6 from simonecorsi/dependabot/npm_and_yarn/handlebars-4.7.7
build(deps): bump handlebars from 4.7.6 to 4.7.7
2021-05-19 11:24:02 +02:00
Simone Corsi
bbc8ec9ca5 Merge pull request #8 from simonecorsi/dependabot/npm_and_yarn/lodash-4.17.21
build(deps): bump lodash from 4.17.20 to 4.17.21
2021-05-19 11:23:53 +02:00
dependabot[bot]
10151792e7 build(deps): bump lodash from 4.17.20 to 4.17.21
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.20 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.20...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 23:57:18 +00:00
dependabot[bot]
012928bcda build(deps): bump handlebars from 4.7.6 to 4.7.7
Bumps [handlebars](https://github.com/wycats/handlebars.js) from 4.7.6 to 4.7.7.
- [Release notes](https://github.com/wycats/handlebars.js/releases)
- [Changelog](https://github.com/handlebars-lang/handlebars.js/blob/master/release-notes.md)
- [Commits](https://github.com/wycats/handlebars.js/compare/v4.7.6...v4.7.7)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-09 12:33:24 +00:00
Conventional Changelog Action
fe15d9358c chore(release): v1.0.32 2021-01-22 14:34:57 +00:00
Simone Corsi
5753aefaa3 docs: added documentation 2021-01-22 15:33:27 +01:00
GitHub Actions
fb228f6b20 Merge branch 'main' of github.com:simonecorsi/mawesome into main 2021-01-22 15:23:53 +01:00
Conventional Changelog Action
903c070e54 chore(release): v1.0.31 2021-01-21 21:53:35 +00:00
Simone Corsi
58a7dc17bf feat: added user/email input for commiting 2021-01-21 22:53:21 +01:00
GitHub Actions
3ad155575d chore: removed unused npm packages 2021-01-19 11:17:49 +01:00
10 changed files with 175 additions and 961 deletions

View File

@@ -1,36 +1,36 @@
## <small>1.0.30 (2021-01-16)</small>
## <small>1.0.37 (2021-06-23)</small>
* fix: removed push ([7f42ca0](https://github.com/simonecorsi/mawesome/commit/7f42ca0))
* 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.29 (2021-01-16)</small>
## <small>1.0.36 (2021-06-23)</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.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.28 (2021-01-16)</small>
## <small>1.0.35 (2021-06-22)</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.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.27 (2021-01-16)</small>
## <small>1.0.34 (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.34 ([ab02c0d](https://github.com/simonecorsi/mawesome/commit/ab02c0d))
## <small>1.0.26 (2021-01-16)</small>
## <small>1.0.33 (2021-05-19)</small>
* chore: added link to project ([0543c05](https://github.com/simonecorsi/mawesome/commit/0543c05))
* chore(release): v1.0.26 ([8bc2714](https://github.com/simonecorsi/mawesome/commit/8bc2714))
* 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))

View File

@@ -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 }}
```

View File

@@ -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'

View File

@@ -21308,9 +21308,11 @@ class Git {
this.createTag = (tag) => this.exec(`tag -a ${tag} -m "${tag}"`);
const githubToken = core.getInput('github-token', { required: true });
core.setSecret(githubToken);
const githubName = core.getInput('github-name') || 'GitHub Actions';
const githubEmail = core.getInput('github-email') || 'actions@users.noreply.github.com';
// Set config
this.config('user.name', 'GitHub Actions');
this.config('user.email', 'actions@users.noreply.github.com');
this.config('user.name', githubName);
this.config('user.email', githubEmail);
this.config('pull.rebase', 'false');
// Update the origin
this.updateOrigin(`https://x-access-token:${githubToken}@github.com/${GITHUB_REPOSITORY}.git`);
@@ -21359,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));
@@ -21431,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;
/***/ }),
@@ -21509,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

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "mawesome",
"version": "1.0.30",
"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",

View File

@@ -11,9 +11,13 @@ class Git {
const githubToken = core.getInput('github-token', { required: true });
core.setSecret(githubToken);
const githubName = core.getInput('github-name') || 'GitHub Actions';
const githubEmail =
core.getInput('github-email') || 'actions@users.noreply.github.com';
// Set config
this.config('user.name', 'GitHub Actions');
this.config('user.email', 'actions@users.noreply.github.com');
this.config('user.name', githubName);
this.config('user.email', githubEmail);
this.config('pull.rebase', 'false');
// Update the origin

View File

@@ -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();
}

View File

@@ -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> {

View File

@@ -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'));