Przeglądaj źródła

Create-a-theme-checklist can also get the Github token from the environment (#6206)

In addition to hard coding a Github token in the actual `create-a-theme-checklist.js` file, we now have the option to read the token from the `THEME_GITHUB_TOKEN` environment variable.

This approach has the benefit of not including a secret like a token in source code.
Mark Biek 3 lat temu
rodzic
commit
b7473032d1
1 zmienionych plików z 13 dodań i 4 usunięć
  1. 13 4
      create-a-theme-checklist.js

+ 13 - 4
create-a-theme-checklist.js

@@ -5,10 +5,19 @@ if ( ! theme ) {
 	return;
 }
 
-const { Octokit } = require( 'octokit' );
-const octokit = new Octokit( {
-	auth: `PUT YOUR ACCESS TOKEN HERE`,
-} );
+/**
+ * We need a Github personal access token to continue.
+ *
+ * The most robust way is to add an environment variable to your ~/.bashrc or ~/.zshrc depending on the shell you're using. To check which shell you're using, run `echo $SHELL` in a terminal.
+ *
+ * The environment variable in your shell rc should look like this:
+ * export THEME_GITHUB_TOKEN=<insert your token>
+ *
+ * Alternatively, you can replace `PUT YOUR ACCESS TOKEN HERE` with the actual access token value.
+ */
+const octokit = new Octokit({
+	auth: process.env.THEME_GITHUB_TOKEN || `PUT YOUR ACCESS TOKEN HERE`,
+});
 
 function sleep( ms ) {
 	return new Promise( ( resolve ) => {