Skip to content

Commit 0940fc1

Browse files
gr2mpanva
andauthored
fix: move github api requests to after git checks (#713)
Co-authored-by: Filip Skokan <[email protected]>
1 parent 488876a commit 0940fc1

File tree

2 files changed

+28
-28
lines changed

2 files changed

+28
-28
lines changed

dist/index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34310,7 +34310,7 @@ async function main() {
3431034310
if (!process.env.GITHUB_TOKEN) {
3431134311
core.setFailed(
3431234312
`GITHUB_TOKEN is not configured. Make sure you made it available to your action
34313-
34313+
3431434314
uses: gr2m/create-or-update-pull-request-action@master
3431534315
env:
3431634316
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}`
@@ -34331,10 +34331,6 @@ async function main() {
3433134331
return;
3433234332
}
3433334333

34334-
const octokit = new Octokit({
34335-
auth: process.env.GITHUB_TOKEN,
34336-
});
34337-
3433834334
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
3433934335

3434034336
try {
@@ -34366,15 +34362,6 @@ async function main() {
3436634362
process.exit(1);
3436734363
}
3436834364

34369-
const {
34370-
data: { default_branch },
34371-
} = await octokit.request(`GET /repos/{owner}/{repo}`, {
34372-
owner,
34373-
repo,
34374-
});
34375-
const DEFAULT_BRANCH = default_branch;
34376-
core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`);
34377-
3437834365
const { hasChanges } = await getLocalChanges(inputs.path);
3437934366

3438034367
if (!hasChanges) {
@@ -34425,6 +34412,19 @@ async function main() {
3442534412
`git rev-parse --abbrev-ref HEAD`
3442634413
);
3442734414

34415+
const octokit = new Octokit({
34416+
auth: process.env.GITHUB_TOKEN,
34417+
});
34418+
34419+
const {
34420+
data: { default_branch },
34421+
} = await octokit.request(`GET /repos/{owner}/{repo}`, {
34422+
owner,
34423+
repo,
34424+
});
34425+
const DEFAULT_BRANCH = default_branch;
34426+
core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`);
34427+
3442834428
if (currentBranch === DEFAULT_BRANCH) {
3442934429
core.info(`Already in base branch "${currentBranch}".`);
3443034430
} else {

index.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ async function main() {
1515
if (!process.env.GITHUB_TOKEN) {
1616
core.setFailed(
1717
`GITHUB_TOKEN is not configured. Make sure you made it available to your action
18-
18+
1919
uses: gr2m/create-or-update-pull-request-action@master
2020
env:
2121
GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}`
@@ -36,10 +36,6 @@ async function main() {
3636
return;
3737
}
3838

39-
const octokit = new Octokit({
40-
auth: process.env.GITHUB_TOKEN,
41-
});
42-
4339
const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/");
4440

4541
try {
@@ -71,15 +67,6 @@ async function main() {
7167
process.exit(1);
7268
}
7369

74-
const {
75-
data: { default_branch },
76-
} = await octokit.request(`GET /repos/{owner}/{repo}`, {
77-
owner,
78-
repo,
79-
});
80-
const DEFAULT_BRANCH = default_branch;
81-
core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`);
82-
8370
const { hasChanges } = await getLocalChanges(inputs.path);
8471

8572
if (!hasChanges) {
@@ -130,6 +117,19 @@ async function main() {
130117
`git rev-parse --abbrev-ref HEAD`
131118
);
132119

120+
const octokit = new Octokit({
121+
auth: process.env.GITHUB_TOKEN,
122+
});
123+
124+
const {
125+
data: { default_branch },
126+
} = await octokit.request(`GET /repos/{owner}/{repo}`, {
127+
owner,
128+
repo,
129+
});
130+
const DEFAULT_BRANCH = default_branch;
131+
core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`);
132+
133133
if (currentBranch === DEFAULT_BRANCH) {
134134
core.info(`Already in base branch "${currentBranch}".`);
135135
} else {

0 commit comments

Comments
 (0)