From 84bc6682c5398e492cafea6663ea38d0ac978cb7 Mon Sep 17 00:00:00 2001 From: Harry Marr Date: Tue, 16 Mar 2021 12:44:27 -0400 Subject: [PATCH] Switch to a JavaScript action --- Dockerfile | 15 --------------- action.yml | 8 ++++++++ entrypoint.sh | 14 -------------- index.js | 14 ++++++++++++++ 4 files changed, 22 insertions(+), 29 deletions(-) delete mode 100644 Dockerfile create mode 100644 action.yml delete mode 100755 entrypoint.sh create mode 100644 index.js diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f510716..0000000 --- a/Dockerfile +++ /dev/null @@ -1,15 +0,0 @@ -FROM alpine - -LABEL "repository"="http://github.com/hmarr/debug-action" -LABEL "homepage"="http://github.com/hmarr/debug-action" -LABEL "maintainer"="Harry Marr " - -LABEL "com.github.actions.name"="Debug Action" -LABEL "com.github.actions.description"="Log the action's environment variables and event payload" -LABEL "com.github.actions.icon"="code" -LABEL "com.github.actions.color"="yellow" - -RUN apk --no-cache add jq - -ADD entrypoint.sh /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..62330f1 --- /dev/null +++ b/action.yml @@ -0,0 +1,8 @@ +name: 'Debug action' +description: "Log the action's environment variables and event payload" +branding: + icon: 'code' + color: 'yellow' +runs: + using: 'node12' + main: 'index.js' diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100755 index d677696..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -echo -echo "-- Environment variables ----------------------------------------------" -env -echo "-----------------------------------------------------------------------" - -echo -echo "-- Event JSON ---------------------------------------------------------" -cat "$GITHUB_EVENT_PATH" | jq -M . -echo "-----------------------------------------------------------------------" -echo diff --git a/index.js b/index.js new file mode 100644 index 0000000..5fece19 --- /dev/null +++ b/index.js @@ -0,0 +1,14 @@ +const fs = require("fs"); + +// Output environment variables. Secrets are automatically masked. +console.log("::group::Environment variables") +for (const [key, value] of Object.entries(process.env).sort()) { + console.log(`${key}=${value}`); +} +console.log("::endgroup::") + +// Output prettified event JSON. +console.log("::group::Event JSON") +const event = JSON.parse(fs.readFileSync(process.env["GITHUB_EVENT_PATH"])); +console.log(JSON.stringify(event, null, 2)); +console.log("::endgroup::")