Re-write configure action in JS

This commit is contained in:
Volodymyr Zotov
2025-07-30 12:25:30 -05:00
parent 4923638555
commit 9de113048d
6 changed files with 27615 additions and 31 deletions

2
.gitignore vendored
View File

@@ -1,2 +1,2 @@
coverage/
node_modules/
node_modules/

View File

@@ -9,12 +9,5 @@ inputs:
service-account-token:
description: Your 1Password service account token
runs:
using: composite
steps:
- 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
using: "node20"
main: "dist/index.js"

27586
configure/dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -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

25
configure/index.js Normal file
View File

@@ -0,0 +1,25 @@
const core = require("@actions/core");
const configure = () => {
const OP_CONNECT_HOST =
process.env.INPUT_CONNECT_HOST || process.env.OP_CONNECT_HOST;
const OP_CONNECT_TOKEN =
process.env.INPUT_CONNECT_TOKEN || process.env.CONNECT_TOKEN;
const OP_SERVICE_ACCOUNT_TOKEN =
process.env.INPUT_SERVICE_ACCOUNT_TOKEN ||
process.env.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();

View File

@@ -9,6 +9,7 @@
},
"scripts": {
"build": "ncc build ./src/index.ts",
"build:configure": "ncc build ./configure/index.js -o ./configure/dist",
"format": "prettier --ignore-path ./config/.prettierignore",
"format:check": "npm run format -- --check ./",
"format:write": "npm run format -- --write ./",