Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
no more token prompts

Gregor Martynus gr2m

💭
no more token prompts
View GitHub Profile
View create-gist-from-clipboard.js
// Menu: Create gist from clipboard
// Description: Creates a new GitHub Gist with the contents of your current clipboard
// Author: Gregor Martynus
// Twitter: @gr2m
// https://github.com/gr2m/scriptkit-octokit/
const { Octokit } = await npm("scriptkit-octokit");
const octokit = new Octokit({
auth: {
scopes: ["gist"],
View set-github-status-with-octokit.js
// Menu: Set GitHub Status with Octokit
// Description: Sets the status text on your GitHub Profile
const { Octokit } = await npm("scriptkit-octokit");
const octokit = new Octokit({
auth: {
scopes: ["user"],
env: "GITHUB_TOKEN_SET_USER_PROFILE",
},
});
View set-github-status.js
//Shortcut: command shift -
// Menu: Set GitHub Status
// Description: Sets the status text on your GitHub Profile
const message = await arg("What would you like to say?");
const token = await env("GITHUB_STATUS_TOKEN", {
secret: true,
ignoreBlur: true,
hint: md(
`Create a token [on GitHub](https://github.com/settings/tokens/new?scopes=user&description=kit%20script)`
@gr2m
gr2m / copy-github-name.js
Last active Apr 30, 2021
A Kit script (https://www.scriptkit.com/) to copy the first name of a GitHub user
View copy-github-name.js
// Menu: Copy GitHub user name
// Description: Copies a GitHub user's first name, fallback to @login
// Author: Gregor Martynus
// Twitter: @gr2m
const { Octokit } = await npm("octokit");
const { createOAuthDeviceAuth } = await npm("@octokit/auth-oauth-device");
// set GitHub Token unless it's already set
@gr2m
gr2m / demo.gif
Last active Feb 24, 2021
Deno script which uses Octokit with the OAuth Device authentication strategy
View 01_README.md

Setup

git clone https://gist.github.com/08a749b9eb98ba73e83184894d78675c.git probot-1371
cd probot-1371
npm install

Then run

@gr2m
gr2m / github-action-cypress-against-now-deployment.yaml
Created Mar 2, 2020
Example GitHub Action workflow which runs Cypress using now's deployment for the current commit. See https://mobile.twitter.com/gr2m/status/1234602143719419904
View github-action-cypress-against-now-deployment.yaml
name: End-to-end tests
on: [push]
jobs:
cypress-run:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
@gr2m
gr2m / create_new_octokit_js_repository.md
Last active Oct 8, 2019
I found myself create new Octokit repositories all the time, due to its decomposable and extendable architecture. Here is how I do it for future reference. Ideally, this would all be automated using an `npm init octokit` script
View create_new_octokit_js_repository.md

Create new Octokit (JS) repository

Example

  • repository name: action.js
  • description: GitHub API client for GitHub Actions
# create new folder and change into it
mkdir action.js
@gr2m
gr2m / using_ecmascript_modules_for_octokit.md
Last active Oct 9, 2019
Living document to make the Octokit JS libraries (https://github.com/octokit?utf8=%E2%9C%93&q=.js&type=&language=) work with ECMAScript Modules, Common JS and modern browsers
View using_ecmascript_modules_for_octokit.md

My usecase: Universal JavaScript libraries for GitHub's APIs for Node.js and modern browsers.

All libraries are written in Typescript, so a build step is necessary which makes it easier to seperate the source code structure from the distribution code structure. I rely heavily on pika.dev for creating browser bundles and distributing them via their CDN. Example: https://github.com/octokit/request.js/#usage.

I use @pika/pack to create a ./pkg folder with multiple distributions right before publishing to npm. Example: https://unpkg.com/browse/@octokit/request@5.1.0/

Currently, the dist-web/ folder is the ECMAScript Module export, it's referenced using the "module" key in its package.json. The dist-node/ folder is referenced using the "main" key in its package.json.

Besides the differentiation of common