Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ jobs:

# If the coverage percentage is not green and above or equal to this value, the badge will be orange. Otherwise it will be red.
badge-threshold-orange: 70

# Override the default branch name.
default-branch: next
```

### Pinning
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ inputs:
description: If the coverage percentage is not green and above or equal to this value, the badge will be orange. Otherwise it will be red.
default: "70"
required: false
default-branch:
description: Override the default branch name.
required: false
runs:
using: node16
main: dist/index.js
10 changes: 6 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13845,15 +13845,15 @@ function isBranch() {
return process.env.GITHUB_REF.startsWith("refs/heads/");
}

async function isMainBranch(octokit, owner, repo) {
async function isDefaultBranch(octokit, owner, repo) {
let response = await octokit.rest.repos.get({
owner,
repo,
});
return response.data.default_branch === process.env.GITHUB_REF_NAME;
}

module.exports = { isBranch, isMainBranch };
module.exports = { isBranch, isDefaultBranch };


/***/ }),
Expand Down Expand Up @@ -14278,7 +14278,7 @@ const core = __nccwpck_require__(2186);
const github = __nccwpck_require__(5438);

const { gitClone, gitUpdate } = __nccwpck_require__(109);
const { isBranch, isMainBranch } = __nccwpck_require__(6381);
const { isBranch, isDefaultBranch } = __nccwpck_require__(6381);
const { getShieldURL, getJSONBadge } = __nccwpck_require__(3673);
const { average } = __nccwpck_require__(8978);
const { computeDiff } = __nccwpck_require__(1752);
Expand All @@ -14296,6 +14296,7 @@ async function run() {
const baseSummaryFilename = core.getInput("base-summary-filename");
const coverageFilename = core.getInput("coverage-filename");
const badgeThresholdOrange = core.getInput("badge-threshold-orange");
const defaultBranch = core.getInput("default-branch");

core.info(`Cloning wiki repository...`);

Expand All @@ -14315,7 +14316,8 @@ async function run() {

if (
isBranch() &&
(await isMainBranch(octokit, context.repo.owner, context.repo.repo))
(defaultBranch === process.env.GITHUB_REF_NAME ||
(await isDefaultBranch(octokit, context.repo.owner, context.repo.repo)))
) {
core.info("Running on default branch");
const BadgeEnabled = core.getBooleanInput("badge-enabled");
Expand Down
4 changes: 2 additions & 2 deletions src/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ function isBranch() {
return process.env.GITHUB_REF.startsWith("refs/heads/");
}

async function isMainBranch(octokit, owner, repo) {
async function isDefaultBranch(octokit, owner, repo) {
let response = await octokit.rest.repos.get({
owner,
repo,
});
return response.data.default_branch === process.env.GITHUB_REF_NAME;
}

module.exports = { isBranch, isMainBranch };
module.exports = { isBranch, isDefaultBranch };
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const core = require("@actions/core");
const github = require("@actions/github");

const { gitClone, gitUpdate } = require("./git");
const { isBranch, isMainBranch } = require("./branch");
const { isBranch, isDefaultBranch } = require("./branch");
const { getShieldURL, getJSONBadge } = require("./badge");
const { average } = require("./math");
const { computeDiff } = require("./diff");
Expand All @@ -29,6 +29,7 @@ async function run() {
const baseSummaryFilename = core.getInput("base-summary-filename");
const coverageFilename = core.getInput("coverage-filename");
const badgeThresholdOrange = core.getInput("badge-threshold-orange");
const defaultBranch = core.getInput("default-branch");

core.info(`Cloning wiki repository...`);

Expand All @@ -48,7 +49,8 @@ async function run() {

if (
isBranch() &&
(await isMainBranch(octokit, context.repo.owner, context.repo.repo))
(defaultBranch === process.env.GITHUB_REF_NAME ||
(await isDefaultBranch(octokit, context.repo.owner, context.repo.repo)))
) {
core.info("Running on default branch");
const BadgeEnabled = core.getBooleanInput("badge-enabled");
Expand Down