Skip to content

Commit

Permalink
💚 [ci] octokit auth for docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jxn-30 committed Oct 17, 2022
1 parent 54134f7 commit e5584ee
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ jobs:
mkdir -p ./dist/docs
rm -rdf ./dist/docs/*
cp -r ./docs/.vuepress/dist/* ./dist/docs
env:
GITHUB_TOKEN: ${{ github.token }}

- name: '[ℹ️] git diff'
id: git_diff
Expand Down
1 change: 1 addition & 0 deletions docs/.vuepress/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"license": "CC-BY-NC-SA-4.0",
"dependencies": {
"@octokit/auth-action": "2.0.2",
"@primer/octicons": "17.7.0",
"@vuepress/client": "2.0.0-beta.51",
"@vuepress/plugin-pwa": "2.0.0-beta.51",
Expand Down
11 changes: 7 additions & 4 deletions docs/.vuepress/utils/childProcess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ type Util =

export default (utilsPath: string) => ({
run(file: Util, ...args: string[]) {
const result = execFileSync('./node_modules/.bin/ts-node', [
path.join(utilsPath, `${file}.ts`),
...args,
]).toString();
const result = execFileSync(
'./node_modules/.bin/ts-node',
[path.join(utilsPath, `${file}.ts`), ...args],
{
env: process.env,
}
).toString();
if (result) console.log(result);
},
});
5 changes: 4 additions & 1 deletion docs/.vuepress/utils/generate/projectStats.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { execSync } from 'child_process';
import fs from 'fs';

import { createActionAuth } from '@octokit/auth-action';
import { Octokit } from 'octokit';
import Showdown from 'showdown';

Expand Down Expand Up @@ -151,7 +152,9 @@ ${Object.entries(absoluteClocStats)
fs.writeFileSync(clocStatsPath, fullClocResult);

(async () => {
const octokit = new Octokit();
const octokit = new Octokit({
authStrategy: process.env.GITHUB_ACTION ? createActionAuth : undefined,
});

const firstCommit = (
await octokit.rest.repos.listCommits({
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ __metadata:
version: 0.0.0-use.local
resolution: ".vuepress-548500@workspace:docs/.vuepress"
dependencies:
"@octokit/auth-action": 2.0.2
"@primer/octicons": 17.7.0
"@vuepress/client": 2.0.0-beta.51
"@vuepress/plugin-pwa": 2.0.0-beta.51
Expand Down Expand Up @@ -1792,6 +1793,16 @@ __metadata:
languageName: node
linkType: hard

"@octokit/auth-action@npm:2.0.2":
version: 2.0.2
resolution: "@octokit/auth-action@npm:2.0.2"
dependencies:
"@octokit/auth-token": ^3.0.0
"@octokit/types": ^8.0.0
checksum: 033b8776964bfe68ff1f603c56a4e14cfe2d6d13599b025323e1d354d97f8f0a7b0b65b1c19dcb6658261932164dd3b73aaaa46d598f0ad04b054efedc221819
languageName: node
linkType: hard

"@octokit/auth-app@npm:^4.0.0":
version: 4.0.7
resolution: "@octokit/auth-app@npm:4.0.7"
Expand Down

0 comments on commit e5584ee

Please sign in to comment.