Skip to content

Commit 5b8564b

Browse files
committed
init action
1 parent b5c42d4 commit 5b8564b

9 files changed

Lines changed: 612 additions & 0 deletions

File tree

.github/comment-pr.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
on: [pull_request]
2+
3+
jobs:
4+
build:
5+
name: Comment a pull_request
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Checkout
9+
uses: actions/checkout@v2
10+
11+
- name: Comment a pull_request
12+
uses: ./
13+
with:
14+
message: "Hello, It's my first comment with Github action !"
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
lib-cov
2+
*.seed
3+
*.log
4+
*.csv
5+
*.dat
6+
*.out
7+
*.pid
8+
*.gz
9+
*.swp
10+
11+
pids
12+
logs
13+
results
14+
tmp
15+
16+
# Build
17+
public/css/main.css
18+
19+
# Coverage reports
20+
coverage
21+
22+
# API keys and secrets
23+
.env
24+
25+
# Dependency directory
26+
node_modules
27+
bower_components
28+
29+
# Editors
30+
.idea
31+
*.iml
32+
33+
# OS metadata
34+
.DS_Store
35+
Thumbs.db
36+
37+
# Ignore built ts files
38+
dist/**/*
39+
40+
# ignore yarn.lock
41+
yarn.lock

Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM node:10
2+
3+
COPY . .
4+
5+
RUN npm install --production
6+
7+
ENTRYPOINT ["node", "/lib/main.js"]

action.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "action-comment-pull-request"
2+
description: "Comment a pull request with the provided message"
3+
inputs:
4+
message:
5+
description: 'Message that should by displayed inside the pull request'
6+
required: true
7+
GITHUB_TOKEN:
8+
description: 'Github token of the repository'
9+
required: true
10+
runs:
11+
using: 'docker'
12+
image: 'Dockerfile'
13+
args:
14+
- ${{ inputs.message }}
15+
- ${{ inputs.GITHUB_TOKEN }}

lib/main.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"use strict";
2+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4+
return new (P || (P = Promise))(function (resolve, reject) {
5+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8+
step((generator = generator.apply(thisArg, _arguments || [])).next());
9+
});
10+
};
11+
Object.defineProperty(exports, "__esModule", { value: true });
12+
const core = require("@actions/core");
13+
const github = require("@actions/github");
14+
const rest_1 = require("@octokit/rest");
15+
function run() {
16+
return __awaiter(this, void 0, void 0, function* () {
17+
try {
18+
const message = core.getInput('message');
19+
const github_token = core.getInput('GITHUB_TOKEN');
20+
const context = github.context;
21+
if (context.payload.pull_request == null) {
22+
core.setFailed('No pull request found.');
23+
return;
24+
}
25+
const pull_request_number = context.payload.pull_request.number;
26+
const octokit = new rest_1.Octokit({
27+
auth: github_token
28+
});
29+
const new_comment = yield octokit.issues.createComment(Object.assign(Object.assign({}, context.repo), { issue_number: pull_request_number, body: message }));
30+
;
31+
}
32+
catch (error) {
33+
core.setFailed(error.message);
34+
}
35+
});
36+
}
37+
run();

0 commit comments

Comments
 (0)