Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add Version check (#14)
* Add Version check

* Add login & logout.

* Add error message.

* Remove docker build dependency from version check.

* Add create issue action.

* Test review comment on PR.

* Update

* buildpack-pr-comment action

* Add package name & version.

* Enable all steps.

* Set version to 0.0.2.

* Add pr labeling workflow.

* buildpack-create workflow fix.

* buildpack-pr-check corrections.

* buildpack-create

* on pull_request
  • Loading branch information
aarlt authored Jul 8, 2020
commit 9213382c40d30b103d67b11c2753ca88ed404c0c
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