Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/andrioid/setup-pack. Github Action to setup pack for CNCF Buildpacks
Something went wrong. Try again.
setup-pack index.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657import { addPath, getInput, setFailed, info } from "@actions/core";import os from "os";import cache, { extractTar } from "@actions/tool-cache";import { promisify } from "util";import fs from "fs";import path from "path";
const chmod = promisify(fs.chmod);
const FILENAME = "pack";
async function main() { try { const url = getInput("pack-url"); const version = getInput("pack-version"); const platform = "linux"; // TODO: Add other platforms let arch = os.arch(); if (arch === "x64") { arch = "amd64"; }
let toolPath = cache.find(FILENAME, version, arch); if (!toolPath) { const context: { [key: string]: string } = { PLATFORM: platform, PACK_VERSION: version, }; const rendered = url.replace(/\{(\w+?)\}/g, (a, match) => { return context[match] || ""; });
const downloadPath = await cache.downloadTool(rendered); const extractedPath = path.join(await extractTar(downloadPath), FILENAME); toolPath = await cache.cacheFile( extractedPath, FILENAME, FILENAME, version ); }
info("toolpath:" + toolPath);
await chmod(path.join(toolPath, FILENAME), 0o755); addPath(toolPath); } catch (err) { setFailed(err.message); }}
if (require.main === module) { main().catch((err) => { console.error(err.stack); process.exit(1); });}