Skip to content

Test build. #16

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

Open
wants to merge 19 commits into
base: docker-workflow
Choose a base branch
from
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
13 changes: 13 additions & 0 deletions .github/actions/buildpack-pr-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
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: ""
label:
description: "Label to check for"
required: true
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"
}
}
59 changes: 59 additions & 0 deletions .github/actions/buildpack-pr-check/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 pull_request = await octokit.pulls.get({
...context.repo,
pull_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(
"publish",
pull_request.data.labels
.some(label => label.name === core.getInput("label"))
.toString()
);
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