Re-write configure action in JS
This commit is contained in:
@@ -9,12 +9,5 @@ inputs:
|
|||||||
service-account-token:
|
service-account-token:
|
||||||
description: Your 1Password service account token
|
description: Your 1Password service account token
|
||||||
runs:
|
runs:
|
||||||
using: composite
|
using: "node20"
|
||||||
steps:
|
main: "dist/index.js"
|
||||||
- shell: bash
|
|
||||||
env:
|
|
||||||
INPUT_CONNECT_HOST: ${{ inputs.connect-host }}
|
|
||||||
INPUT_CONNECT_TOKEN: ${{ inputs.connect-token }}
|
|
||||||
INPUT_SERVICE_ACCOUNT_TOKEN: ${{ inputs.service-account-token }}
|
|
||||||
run: |
|
|
||||||
${{ github.action_path }}/entrypoint.sh
|
|
||||||
|
|||||||
34
configure/dist/index.js
vendored
Normal file
34
configure/dist/index.js
vendored
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
/******/ /* webpack/runtime/compat */
|
||||||
|
/******/
|
||||||
|
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = new URL('.', import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/) ? 1 : 0, -1) + "/";
|
||||||
|
/******/
|
||||||
|
/************************************************************************/
|
||||||
|
var __webpack_exports__ = {};
|
||||||
|
const core = require("@actions/core");
|
||||||
|
|
||||||
|
const configure = () => {
|
||||||
|
const OP_CONNECT_HOST =
|
||||||
|
core.getInput("connect-host", { required: false }) ||
|
||||||
|
process.env.OP_CONNECT_HOST;
|
||||||
|
const OP_CONNECT_TOKEN =
|
||||||
|
core.getInput("connect-token", { required: false }) ||
|
||||||
|
process.env.OP_CONNECT_TOKEN;
|
||||||
|
const OP_SERVICE_ACCOUNT_TOKEN =
|
||||||
|
core.getInput("service-account-token", { required: false }) ||
|
||||||
|
process.env.OP_SERVICE_ACCOUNT_TOKEN;
|
||||||
|
|
||||||
|
if (OP_CONNECT_HOST) {
|
||||||
|
core.exportVariable("OP_CONNECT_HOST", OP_CONNECT_HOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OP_CONNECT_TOKEN) {
|
||||||
|
core.exportVariable("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OP_SERVICE_ACCOUNT_TOKEN) {
|
||||||
|
core.exportVariable("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
configure();
|
||||||
|
|
||||||
3
configure/dist/package.json
vendored
Normal file
3
configure/dist/package.json
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"type": "module"
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# shellcheck disable=SC2086
|
|
||||||
set -e
|
|
||||||
|
|
||||||
# Capture Connect configuration in $GITHUB_ENV, giving (optional) inputs
|
|
||||||
# precendence over OP_CONNECT_* environment variables.
|
|
||||||
|
|
||||||
OP_CONNECT_HOST="${INPUT_CONNECT_HOST:-$OP_CONNECT_HOST}"
|
|
||||||
if [ -n "$OP_CONNECT_HOST" ]; then
|
|
||||||
echo "OP_CONNECT_HOST=$OP_CONNECT_HOST" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
OP_CONNECT_TOKEN="${INPUT_CONNECT_TOKEN:-$OP_CONNECT_TOKEN}"
|
|
||||||
if [ -n "$OP_CONNECT_TOKEN" ]; then
|
|
||||||
echo "OP_CONNECT_TOKEN=$OP_CONNECT_TOKEN" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
|
|
||||||
OP_SERVICE_ACCOUNT_TOKEN="${INPUT_SERVICE_ACCOUNT_TOKEN:-$OP_SERVICE_ACCOUNT_TOKEN}"
|
|
||||||
if [ -n "$OP_SERVICE_ACCOUNT_TOKEN" ]; then
|
|
||||||
echo "OP_SERVICE_ACCOUNT_TOKEN=$OP_SERVICE_ACCOUNT_TOKEN" >> $GITHUB_ENV
|
|
||||||
fi
|
|
||||||
27
configure/index.js
Normal file
27
configure/index.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
const core = require("@actions/core");
|
||||||
|
|
||||||
|
const configure = () => {
|
||||||
|
const OP_CONNECT_HOST =
|
||||||
|
core.getInput("connect-host", { required: false }) ||
|
||||||
|
process.env.OP_CONNECT_HOST;
|
||||||
|
const OP_CONNECT_TOKEN =
|
||||||
|
core.getInput("connect-token", { required: false }) ||
|
||||||
|
process.env.OP_CONNECT_TOKEN;
|
||||||
|
const OP_SERVICE_ACCOUNT_TOKEN =
|
||||||
|
core.getInput("service-account-token", { required: false }) ||
|
||||||
|
process.env.OP_SERVICE_ACCOUNT_TOKEN;
|
||||||
|
|
||||||
|
if (OP_CONNECT_HOST) {
|
||||||
|
core.exportVariable("OP_CONNECT_HOST", OP_CONNECT_HOST);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OP_CONNECT_TOKEN) {
|
||||||
|
core.exportVariable("OP_CONNECT_TOKEN", OP_CONNECT_TOKEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OP_SERVICE_ACCOUNT_TOKEN) {
|
||||||
|
core.exportVariable("OP_SERVICE_ACCOUNT_TOKEN", OP_SERVICE_ACCOUNT_TOKEN);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
configure();
|
||||||
@@ -9,6 +9,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "ncc build ./src/index.ts",
|
"build": "ncc build ./src/index.ts",
|
||||||
|
"build:configure": "ncc build ./configure/index.js -o ./configure/dist",
|
||||||
"format": "prettier --ignore-path ./config/.prettierignore",
|
"format": "prettier --ignore-path ./config/.prettierignore",
|
||||||
"format:check": "npm run format -- --check ./",
|
"format:check": "npm run format -- --check ./",
|
||||||
"format:write": "npm run format -- --write ./",
|
"format:write": "npm run format -- --write ./",
|
||||||
|
|||||||
Reference in New Issue
Block a user