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
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v3

- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
message: |
Hello world ! :wave:
Expand All @@ -35,7 +35,7 @@ You can either pass an absolute filePath or a relative one that will be by defau

```yml
- name: PR comment with file
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
filePath: /path/to/file.txt
```
Expand All @@ -48,7 +48,7 @@ It takes only valid reactions and adds it to the comment you've just created. (S

```yml
- name: PR comment with reactions
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
message: |
Hello world ! :wave:
Expand All @@ -63,7 +63,7 @@ That is particularly useful for manual workflow for instance (`workflow_run`).
```yml
...
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
message: |
Hello world ! :wave:
Expand All @@ -83,7 +83,7 @@ _That is particularly interesting while committing multiple times in a PR and th
```yml
...
- name: Comment PR with execution number
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
message: |
_(execution **${{ github.run_id }}** / attempt **${{ github.run_attempt }}**)_
Expand All @@ -101,7 +101,7 @@ This will delete the comment at the end of the job.
```yml
...
- name: Write a comment that will be deleted at the end of the job
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
with:
message: |
The PR is being built...
Expand Down Expand Up @@ -142,7 +142,7 @@ You can get some outputs from this actions :

```yaml
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
uses: yorhodes/actions-comment-pull-request@v2
id: hello
with:
message: |
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ inputs:
description: 'Message that should be printed in the pull request'
filePath:
description: 'Path of the file that should be commented'
header:
description: 'Header of the comment'
mdLanguage:
description: 'Syntax highlighting language for the comment (content from filePath)'
GITHUB_TOKEN:
description: 'Github token of the repository (automatically created by Github)'
default: ${{ github.token }}
Expand Down
4 changes: 2 additions & 2 deletions lib/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9536,8 +9536,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const github = __importStar(__nccwpck_require__(5438));
const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
async function run() {
try {
const github_token = core.getInput('GITHUB_TOKEN');
Expand All @@ -9559,7 +9559,7 @@ async function run() {
core.setFailed('No issue/pull request in input neither in current context.');
return;
}
const comment_tag_pattern = `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`;
const comment_tag_pattern = `<!-- yorhodes/actions-comment-pull-request "${comment_tag}" -->`;
if (comment_tag_pattern) {
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
...context.repo,
Expand Down
19 changes: 16 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9539,15 +9539,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs_1 = __importDefault(__nccwpck_require__(7147));
const github = __importStar(__nccwpck_require__(5438));
const core = __importStar(__nccwpck_require__(2186));
const github = __importStar(__nccwpck_require__(5438));
const fs_1 = __importDefault(__nccwpck_require__(7147));
// See https://docs.github.com/en/rest/reactions#reaction-types
const REACTIONS = ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'];
async function run() {
try {
const message = core.getInput('message');
const filePath = core.getInput('filePath');
const header = core.getInput('header');
const mdLanguage = core.getInput('mdLanguage');
const github_token = core.getInput('GITHUB_TOKEN');
const pr_number = core.getInput('pr_number');
const comment_tag = core.getInput('comment_tag');
Expand All @@ -9561,6 +9563,17 @@ async function run() {
let content = message;
if (!message && filePath) {
content = fs_1.default.readFileSync(filePath, 'utf8');
// exit if file is empty (and do not comment)
if (content.length === 0) {
core.info('File is empty. Exiting.');
return;
}
if (mdLanguage) {
content = `\`\`\`${mdLanguage}\n${content}\n\`\`\``;
}
}
if (header) {
content = `# ${header}\n${content}`;
}
const context = github.context;
const issue_number = parseInt(pr_number) || context.payload.pull_request?.number || context.payload.issue?.number;
Expand Down Expand Up @@ -9617,7 +9630,7 @@ async function run() {
return comment;
}
const comment_tag_pattern = comment_tag
? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`
? `<!-- yorhodes/actions-comment-pull-request "${comment_tag}" -->`
: null;
const body = comment_tag_pattern ? `${content}\n${comment_tag_pattern}` : content;
if (comment_tag_pattern) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"repository": {
"type": "git",
"url": "git+https://github.com/thollander/actions-comment-pull-request"
"url": "git+https://github.com/yorhodes/actions-comment-pull-request"
},
"keywords": [
"actions",
Expand All @@ -23,9 +23,9 @@
"author": "Térence Hollander",
"license": "MIT",
"bugs": {
"url": "https://github.com/thollander/actions-comment-pull-request/issues"
"url": "https://github.com/yorhodes/actions-comment-pull-request/issues"
},
"homepage": "https://github.com/thollander/actions-comment-pull-request#readme",
"homepage": "https://github.com/yorhodes/actions-comment-pull-request#readme",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/exec": "^1.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/cleanup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as github from '@actions/github';
import * as core from '@actions/core';
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';
import * as github from '@actions/github';

async function run() {
try {
Expand Down Expand Up @@ -29,7 +28,7 @@ async function run() {
return;
}

const comment_tag_pattern = `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`;
const comment_tag_pattern = `<!-- yorhodes/actions-comment-pull-request "${comment_tag}" -->`;

if (comment_tag_pattern) {
for await (const { data: comments } of octokit.paginate.iterator(octokit.rest.issues.listComments, {
Expand Down
22 changes: 19 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import * as github from '@actions/github';
import * as core from '@actions/core';
import * as github from '@actions/github';
import { GetResponseDataTypeFromEndpointMethod } from '@octokit/types';
import fs from 'fs';

// See https://docs.github.com/en/rest/reactions#reaction-types
const REACTIONS = ['+1', '-1', 'laugh', 'confused', 'heart', 'hooray', 'rocket', 'eyes'] as const;
Expand All @@ -11,6 +11,8 @@ async function run() {
try {
const message: string = core.getInput('message');
const filePath: string = core.getInput('filePath');
const header: string = core.getInput('header');
const mdLanguage: string = core.getInput('mdLanguage');
const github_token: string = core.getInput('GITHUB_TOKEN');
const pr_number: string = core.getInput('pr_number');
const comment_tag: string = core.getInput('comment_tag');
Expand All @@ -26,6 +28,20 @@ async function run() {
let content: string = message;
if (!message && filePath) {
content = fs.readFileSync(filePath, 'utf8');

// exit if file is empty (and do not comment)
if (content.length === 0) {
core.info('File is empty. Exiting.');
return;
}

if (mdLanguage) {
content = `\`\`\`${mdLanguage}\n${content}\n\`\`\``;
}
}

if (header) {
content = `# ${header}\n${content}`;
}

const context = github.context;
Expand Down Expand Up @@ -120,7 +136,7 @@ async function run() {
}

const comment_tag_pattern = comment_tag
? `<!-- thollander/actions-comment-pull-request "${comment_tag}" -->`
? `<!-- yorhodes/actions-comment-pull-request "${comment_tag}" -->`
: null;
const body = comment_tag_pattern ? `${content}\n${comment_tag_pattern}` : content;

Expand Down