Skip to content

Add Version check #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jul 8, 2020
Merged
11 changes: 11 additions & 0 deletions .github/actions/buildpack-pr-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: "Checks whether a PR is buildpack related"
description: "Checks whether a PR is buildpack related"
inputs:
token:
description: "GitHub access token"
required: true
default: ""
runs:
using: "node12"
main: "dist/index.js"

394 changes: 394 additions & 0 deletions .github/actions/buildpack-pr-check/package-lock.json

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions .github/actions/buildpack-pr-check/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "buildpack-pr-check",
"version": "1.0.0",
"description": "An action that checks whether a pr was buildpack related",
"private": true,
"main": "index.js",
"scripts": {
"build": "tsc"
},
"keywords": [],
"author": "Alexander Arlt",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.4",
"@actions/github": "^2.1.1"
},
"devDependencies": {
"typescript": "^3.8.3"
}
}
48 changes: 48 additions & 0 deletions .github/actions/buildpack-pr-check/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import * as core from "@actions/core";
import * as github from "@actions/github";

async function run() {
const token = core.getInput("token");

const octokit = new github.GitHub(token);
const context = github.context;

const comments = await octokit.issues.listComments({
...context.repo,
issue_number: context.payload.pull_request!.number
});

const actionComment = comments.data.find(
comment => comment.body.indexOf("Package: ") >= 0 &&
comment.body.indexOf("Version: ") >= 0 &&
comment.body.indexOf("Action: ") >= 0 &&
comment.body.indexOf("Artifact: ") >= 0 &&
comment.body.indexOf("Commit: ") >= 0
);

if (actionComment) {
let pack = actionComment!.body.substr(actionComment!.body.indexOf("Package: ") + 9)
pack = pack.substr(0, pack.indexOf("\n"));
let version = actionComment!.body.substr(actionComment!.body.indexOf("Version: ") + 9)
version = version.substr(0, version.indexOf("\n"));
let action = actionComment!.body.substr(actionComment!.body.indexOf("Action: ") + 8)
action = action.substr(0, action.indexOf("\n"));
let artifact = actionComment!.body.substr(actionComment!.body.indexOf("Artifact: ") + 10)
artifact = artifact.substr(0, artifact.indexOf("\n"));
let commit = actionComment!.body.substr(actionComment!.body.indexOf("Commit: ") + 8)

core.setOutput("package", pack.trim());
core.setOutput("version", version.trim());
core.setOutput("action", action.trim());
core.setOutput("artifact", artifact.trim());
core.setOutput("commit", commit.trim());

console.log("package", pack.trim());
console.log("version", version.trim());
console.log("action", action.trim());
console.log("artifact", artifact.trim());
console.log("commit", commit.trim());
}
}

run();
10 changes: 10 additions & 0 deletions .github/actions/buildpack-pr-check/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"outDir": "dist"
}
}
26 changes: 26 additions & 0 deletions .github/actions/buildpack-pr-comment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: "Add comment to current PR"
description: "Adds a comment to current PR"
inputs:
token:
description: "GitHub access token"
required: true
default: ""
action-id:
description: "GitHub Action ID"
required: true
default: ""
package-name:
description: "Name of the package being released"
required: true
default: "Something like buildpack-ubuntu2004"
package-version:
description: "Version of the package being released"
required: true
default: "Something like 1.0.0"
artifact:
description: "Name of the artifact"
required: true
default: "Something like buildpack-ubuntu2004-d12f0d12c9f69baa7b825033b2f9c89acea738bf1ae734efa4b343833f897e1d"
runs:
using: "node12"
main: "dist/index.js"
Loading