diff --git a/dist/index.js b/dist/index.js index 125d247a..2e231ab9 100644 --- a/dist/index.js +++ b/dist/index.js @@ -34310,7 +34310,7 @@ async function main() { if (!process.env.GITHUB_TOKEN) { core.setFailed( `GITHUB_TOKEN is not configured. Make sure you made it available to your action - + uses: gr2m/create-or-update-pull-request-action@master env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}` @@ -34331,10 +34331,6 @@ async function main() { return; } - const octokit = new Octokit({ - auth: process.env.GITHUB_TOKEN, - }); - const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); try { @@ -34366,15 +34362,6 @@ async function main() { process.exit(1); } - const { - data: { default_branch }, - } = await octokit.request(`GET /repos/{owner}/{repo}`, { - owner, - repo, - }); - const DEFAULT_BRANCH = default_branch; - core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`); - const { hasChanges } = await getLocalChanges(inputs.path); if (!hasChanges) { @@ -34425,6 +34412,19 @@ async function main() { `git rev-parse --abbrev-ref HEAD` ); + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + }); + + const { + data: { default_branch }, + } = await octokit.request(`GET /repos/{owner}/{repo}`, { + owner, + repo, + }); + const DEFAULT_BRANCH = default_branch; + core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`); + if (currentBranch === DEFAULT_BRANCH) { core.info(`Already in base branch "${currentBranch}".`); } else { diff --git a/index.js b/index.js index 0a3858dd..cb6a0140 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,7 @@ async function main() { if (!process.env.GITHUB_TOKEN) { core.setFailed( `GITHUB_TOKEN is not configured. Make sure you made it available to your action - + uses: gr2m/create-or-update-pull-request-action@master env: GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}` @@ -36,10 +36,6 @@ async function main() { return; } - const octokit = new Octokit({ - auth: process.env.GITHUB_TOKEN, - }); - const [owner, repo] = process.env.GITHUB_REPOSITORY.split("/"); try { @@ -71,15 +67,6 @@ async function main() { process.exit(1); } - const { - data: { default_branch }, - } = await octokit.request(`GET /repos/{owner}/{repo}`, { - owner, - repo, - }); - const DEFAULT_BRANCH = default_branch; - core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`); - const { hasChanges } = await getLocalChanges(inputs.path); if (!hasChanges) { @@ -130,6 +117,19 @@ async function main() { `git rev-parse --abbrev-ref HEAD` ); + const octokit = new Octokit({ + auth: process.env.GITHUB_TOKEN, + }); + + const { + data: { default_branch }, + } = await octokit.request(`GET /repos/{owner}/{repo}`, { + owner, + repo, + }); + const DEFAULT_BRANCH = default_branch; + core.debug(`DEFAULT_BRANCH: ${DEFAULT_BRANCH}`); + if (currentBranch === DEFAULT_BRANCH) { core.info(`Already in base branch "${currentBranch}".`); } else {