Skip to content

Commit

Permalink
Merge pull request #8 from sidx1024/sid/try-1
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
sidx1024 authored Mar 21, 2022
2 parents 8737a8f + 5f73b47 commit 7d47a02
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # required to detect changed files
fetch-depth: 2 # required to detect changed files
ref: ${{ github.event.pull_request.head.sha }}

- name: Run tests
Expand All @@ -49,7 +49,7 @@ jobs:
<!-- start usage -->
```yaml
- uses: sidx1024/report-nyc-coverage-github-action@v1.1
- uses: sidx1024/report-nyc-coverage-github-action@v1.0.0
with:
# Path to coverage output directory generated by "nyc report".
coverage_output_directory: ""
Expand Down
8 changes: 4 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10044,17 +10044,16 @@ async function run() {

const commentTemplateMDPath = path.resolve(core.getInput(ActionInput.comment_template_file));
const commentTemplate = fs.readFileSync(commentTemplateMDPath, { encoding: 'utf-8' });
let commentBody = replaceTokens(commentTemplate, outputs);

const commentMark = `<!-- ${DEFAULT_COMMENT_MARKER} -->`;
const commentBody = replaceTokens(commentTemplate, outputs) + '\n' + commentMark + '\n';

const commentMode = core.getInput(ActionInput.comment_mode);

const octokit = await github.getOctokit(gitHubToken);
const existingComment =
commentMode === 'replace' ? await findCommentByBody(octokit, commentMark) : null;

if (existingComment) {
commentBody += '\n' + commentMark + '\n';
await octokit.rest.issues.updateComment({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
Expand All @@ -10075,6 +10074,8 @@ async function run() {
});
}

// dummy

async function getChangedFiles() {
const { base, head } = github.context.payload.pull_request;
const { exitCode, output } = await executeCommand(
Expand Down Expand Up @@ -10128,7 +10129,6 @@ async function findCommentByBody(octokit, commentBodyIncludes) {
}

function getFilePrefix() {
console.log('github.context.payload.pull_request', github.context.payload.pull_request);
return `../blob/${github.context.payload.pull_request.head.sha}/`;
}

Expand Down
8 changes: 4 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,16 @@ async function run() {

const commentTemplateMDPath = path.resolve(core.getInput(ActionInput.comment_template_file));
const commentTemplate = fs.readFileSync(commentTemplateMDPath, { encoding: 'utf-8' });
let commentBody = replaceTokens(commentTemplate, outputs);

const commentMark = `<!-- ${DEFAULT_COMMENT_MARKER} -->`;
const commentBody = replaceTokens(commentTemplate, outputs) + '\n' + commentMark + '\n';

const commentMode = core.getInput(ActionInput.comment_mode);

const octokit = await github.getOctokit(gitHubToken);
const existingComment =
commentMode === 'replace' ? await findCommentByBody(octokit, commentMark) : null;

if (existingComment) {
commentBody += '\n' + commentMark + '\n';
await octokit.rest.issues.updateComment({
owner: github.context.repo.owner,
repo: github.context.repo.repo,
Expand All @@ -106,6 +105,8 @@ async function run() {
});
}

// dummy

async function getChangedFiles() {
const { base, head } = github.context.payload.pull_request;
const { exitCode, output } = await executeCommand(
Expand Down Expand Up @@ -159,7 +160,6 @@ async function findCommentByBody(octokit, commentBodyIncludes) {
}

function getFilePrefix() {
console.log('github.context.payload.pull_request', github.context.payload.pull_request);
return `../blob/${github.context.payload.pull_request.head.sha}/`;
}

Expand Down

0 comments on commit 7d47a02

Please sign in to comment.