Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 75c115e

Browse files
authored
Use GITHUB_TOKEN as the env variable for the changelog script (#10697)
1 parent c8d2608 commit 75c115e

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

bin/changelog/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog Script
22

3-
This folder contains the logic for a changelog script that can be used for generating changelog entries from either pull requests added to a Github milestone, or pull requests that are part of a Zenhub release.
3+
This folder contains the logic for a changelog script that can be used for generating changelog entries from either pull requests added to a GitHub milestone, or pull requests that are part of a Zenhub release.
44

55
## Usage
66

@@ -37,16 +37,16 @@ The 'variable' in the following table can be used in `package.json` or as a cli
3737
| defaultPrefix | When there is no label with the `labelPrefix` on a pull, this is the default type that will be used for the changelog entry (defaults to `dev`). |
3838
| changelogSrcType | Either "MILESTONE" (default) or "ZENHUB_RELEASE". This determines what will serve as the source for the changelog entries. |
3939
| devNoteLabel | If a pull has this label then `[DN]` will be appended to the end of the changelog. It's a good way to indicate what entries have (or will have) dev notes. |
40-
| repo | This is the namespace for the github repository used as the source for pulls used in the changelog entries. Example: `'woocommerce/woocommerce-gutenberg-products-block'` |
41-
| ghApiToken | You can pass your github api token to the script. NOTE: Strongly recommend you use environment variable for this. |
42-
| zhApiKey | You can pass your zenhub api key to the script using this config. NOTE: Strongly recommend you use environment variable for this. |
40+
| repo | This is the namespace for the GitHub repository used as the source for pulls used in the changelog entries. Example: `'woocommerce/woocommerce-gutenberg-products-block'` |
41+
| githubToken | You can pass your GitHub API token to the script. NOTE: Strongly recommend you use environment variable for this (`GITHUB_TOKEN`). |
42+
| zhApiKey | You can pass your Zenhub api key to the script using this config. NOTE: Strongly recommend you use environment variable for this. |
4343

4444
The two environment variables you can use are:
4545

4646
| Environment Variable | Description |
4747
| -------------------- | ------------------------------------------------------------- |
48-
| GH_API_TOKEN | Github API token for authorizing on the github API. |
49-
| ZH_API_TOKEN | Zenhub api token used for authorizing against the zenhub API. |
48+
| GITHUB_TOKEN | GitHub API token for authorizing on the GitHub API. |
49+
| ZH_API_TOKEN | Zenhub API token used for authorizing against the Zenhub API. |
5050

5151
### Examples
5252

@@ -66,11 +66,11 @@ The two environment variables you can use are:
6666
#### Environment Variable
6767

6868
```bash
69-
GH_API_TOKEN="1343ASDFQWER13241REASD" node ./bin/changelog
69+
GITHUB_TOKEN="1343ASDFQWER13241REASD" node ./bin/changelog
7070
```
7171

7272
#### Command Line
7373

7474
```bash
75-
node ./bin/changelog --labelPrefix="type:" --skipLabel="skip-changelog" --defaultPrefix="dev" --repo="woocommerce/woocommerce-gutenberg-products-block" --ghApiToken="1343ASDFQWER13241REASD"
75+
node ./bin/changelog --labelPrefix="type:" --skipLabel="skip-changelog" --defaultPrefix="dev" --repo="woocommerce/woocommerce-gutenberg-products-block" --githubToken="1343ASDFQWER13241REASD"
7676
```

bin/changelog/common/get-entry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const { pkg, REPO } = require( '../config' );
77
/* eslint no-console: 0 */
88

99
const headers = {
10-
authorization: `token ${ pkg.changelog.ghApiToken }`,
10+
authorization: `token ${ pkg.changelog.githubToken }`,
1111
'user-agent': 'changelog-tool',
1212
};
1313

bin/changelog/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ const DEFAULTS = {
1717
changelogSrcType: changelogSrcTypes.MILESTONE,
1818
devNoteLabel: 'dev-note',
1919
repo: '',
20-
ghApiToken: '',
20+
githubToken: '',
2121
zhApiToken: '',
2222
};
2323

2424
pkg.changelog = pkg.changelog || DEFAULTS;
2525

2626
config.merge( { ...DEFAULTS, ...pkg.changelog } );
27-
config.env( [ 'GH_API_TOKEN', 'ZH_API_TOKEN' ] );
27+
config.env( [ 'GITHUB_TOKEN', 'ZH_API_TOKEN' ] );
2828
config.argv( Object.keys( DEFAULTS ) );
2929

3030
const REPO = config.get( 'repo' );

bin/changelog/github/make-change-log.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const { fetchAllPullRequests } = require( './requests' );
99
let ready = false;
1010

1111
const makeChangeLog = async () => {
12-
if ( ! pkg.changelog.ghApiToken ) {
12+
if ( ! pkg.changelog.githubToken ) {
1313
console.log(
1414
chalk.yellow(
1515
'This program requires an api token. You can create one here: '
@@ -24,14 +24,14 @@ const makeChangeLog = async () => {
2424
console.log( '' );
2525
console.log(
2626
chalk.yellow(
27-
'Export the token as variable called GH_API_TOKEN from your bash profile.'
27+
'Export the token as variable called GITHUB_TOKEN from your bash profile.'
2828
)
2929
);
3030
console.log( '' );
3131

3232
ready = await promptly.confirm( 'Are you ready to continue? ' );
3333
} else {
34-
console.log( chalk.green( 'Detected GH_API_TOKEN is set.' ) );
34+
console.log( chalk.green( 'Detected GITHUB_TOKEN is set.' ) );
3535
ready = true;
3636
}
3737

bin/changelog/zenhub/make-change-log.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ const { fetchAllPullRequests } = require( './requests' );
99
let ready = false;
1010

1111
const makeChangeLog = async () => {
12-
if ( ! pkg.changelog.zhApiToken || ! pkg.changelog.ghApiToken ) {
12+
if ( ! pkg.changelog.zhApiToken || ! pkg.changelog.githubToken ) {
1313
const zenhubSet = pkg.changelog.zhApiToken
1414
? chalk.green( 'set' )
1515
: chalk.red( 'not set' );
16-
const githubSet = pkg.changelog.ghApiToken
16+
const githubSet = pkg.changelog.githubToken
1717
? chalk.green( 'set' )
1818
: chalk.red( 'not set' );
1919
console.log( `${ chalk.yellow( 'Zenhub Token:' ) } ${ zenhubSet }` );
20-
console.log( `${ chalk.yellow( 'Github Token:' ) } ${ githubSet }` );
20+
console.log( `${ chalk.yellow( 'GitHub Token:' ) } ${ githubSet }` );
2121
console.log( '' );
2222
console.log(
2323
chalk.yellow(
24-
'This program requires an api token from Github and Zenhub.'
24+
'This program requires an api token from GitHub and Zenhub.'
2525
)
2626
);
2727
console.log(
2828
chalk.yellow(
29-
'You can create and get a Github token here: https://github.com/settings/tokens'
29+
'You can create and get a GitHub token here: https://github.com/settings/tokens'
3030
)
3131
);
3232
console.log(
@@ -37,13 +37,13 @@ const makeChangeLog = async () => {
3737
console.log( '' );
3838
console.log(
3939
chalk.yellow(
40-
'Token scope for Github will require read permissions on public_repo, admin:org, and user.'
40+
'Token scope for GitHub will require read permissions on public_repo, admin:org, and user.'
4141
)
4242
);
4343
console.log( '' );
4444
console.log(
4545
chalk.yellow(
46-
'Export the github token as variable called GH_API_TOKEN and the Zenhub token as a variable called ZH_API_TOKEN from your bash profile.'
46+
'Export the github token as variable called GITHUB_TOKEN and the Zenhub token as a variable called ZH_API_TOKEN from your bash profile.'
4747
)
4848
);
4949
console.log( '' );
@@ -52,7 +52,7 @@ const makeChangeLog = async () => {
5252
} else {
5353
console.log(
5454
chalk.green(
55-
'Detected that ZH_API_TOKEN and GH_API_TOKEN values are set.'
55+
'Detected that ZH_API_TOKEN and GITHUB_TOKEN values are set.'
5656
)
5757
);
5858
ready = true;

0 commit comments

Comments
 (0)