Compare commits

...

29 Commits

Author SHA1 Message Date
Volodymyr Zotov
13f58eec61 Merge pull request #110 from 1Password/vzt/prepare-release-v3
Prepare release v3.0.0
2025-08-14 12:25:40 -05:00
Volodymyr Zotov
f9847b316a Merge branch 'main' into vzt/prepare-release-v3
# Conflicts:
#	README.md
2025-08-14 10:01:49 -05:00
Volodymyr Zotov
438a01224c Merge pull request #114 from 1Password/vzt/change-default-export-env
Set `export-env` input to `false` by default
2025-08-14 10:01:11 -05:00
Volodymyr Zotov
ba891d4bf2 Update readme 2025-08-14 09:59:24 -05:00
Volodymyr Zotov
909c7e01f1 Fix formatting 2025-08-13 17:41:42 -05:00
Volodymyr Zotov
1c443d83da Update README.md to show examples of using as step outputs and env vars 2025-08-13 17:35:23 -05:00
Volodymyr Zotov
867fee7815 Set export-env input to false by default 2025-08-13 17:03:58 -05:00
Volodymyr Zotov
ee4b4919bf Make latest build 2025-08-13 16:50:05 -05:00
Volodymyr Zotov
13f110716c Merge branch 'main' into vzt/prepare-release-v3 2025-08-13 16:49:19 -05:00
Volodymyr Zotov
7914f19c4d Merge pull request #113 from 1Password/vzt/bump-op-cli-installer
Bump op-cli-installer version
2025-08-13 16:48:44 -05:00
Volodymyr Zotov
25aa72f51b Point to the latest op-cli-installer commit from main 2025-08-13 16:29:10 -05:00
Volodymyr Zotov
2fa8a509ca Point to the latest main for acceptance tests 2025-08-13 16:08:37 -05:00
Volodymyr Zotov
f30ae37660 Bump to the latest op-cli-installer version that set's defaults 2025-08-13 15:40:06 -05:00
Volodymyr Zotov
93b787fdef Merge branch 'main' into vzt/prepare-release-v3 2025-08-13 15:13:22 -05:00
Volodymyr Zotov
29afdd3b50 Merge pull request #112 from 1Password/vzt/set-default-cli-version
Set default for `version` input
2025-08-13 15:11:49 -05:00
Volodymyr Zotov
c03c0b6bbe Set default for version input 2025-08-13 14:16:47 -05:00
Volodymyr Zotov
cb2930c65f Bump actions/checkout to v4 on readme 2025-08-13 13:25:33 -05:00
Volodymyr Zotov
65a7f5e592 Prepare release v3.0.0 2025-08-13 13:16:21 -05:00
Volodymyr Zotov
a8d5f2a285 Merge pull request #109 from 1Password/vzt/use-op-cli-installer
Use op cli installer to enable Windows support
2025-08-13 12:56:35 -05:00
Volodymyr Zotov
f5fc2382af Treat module as commonjs 2025-08-13 12:06:22 -05:00
Volodymyr Zotov
596d8007a1 Introduce build:all command that bundles both configure and load-secrets-action. Remove type: "module" from package.json so ncc builds CommonJS configure action which is required 2025-08-13 11:59:45 -05:00
Volodymyr Zotov
c9ae724dfd Use latest commit hash for op-cli-installer package 2025-08-08 19:31:32 -05:00
Volodymyr Zotov
40b6ef7b57 Remove verify cli version step from a job to reduce complexity.
This should be properly tested in op-cli-installer package. Current test will confirm that secrets are loaded correctly.
2025-08-08 19:28:20 -05:00
Volodymyr Zotov
a4866d442c Remove bash script 2025-08-05 16:13:17 -05:00
Volodymyr Zotov
10084cd57d Re-build configure action as commonjs 2025-08-05 11:49:35 -05:00
Volodymyr Zotov
d6b7427345 Change configure action type to commonjs 2025-08-05 11:47:12 -05:00
Volodymyr Zotov
96de656797 Re-write configure action in JS 2025-08-05 11:45:36 -05:00
Volodymyr Zotov
c0724d8845 Add more tests to check that action works correctly with provided stable or beta version 2025-08-05 11:45:36 -05:00
Volodymyr Zotov
3a62b7cf63 Use op-cli-installer package to install CLI 2025-08-05 10:37:09 -05:00
15 changed files with 36604 additions and 3847 deletions

View File

@@ -15,17 +15,21 @@ on:
export-env:
required: true
type: boolean
version:
required: false
type: string
default: "latest"
os:
required: true
type: string
default: "ubuntu-latest"
auth:
required: true
type: string
jobs:
acceptance-test:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
auth: [connect, service-account]
exclude:
- os: macos-latest
auth: connect
runs-on: ${{ matrix.os }}
runs-on: ${{ inputs.os }}
steps:
- name: Base checkout
uses: actions/checkout@v4
@@ -50,27 +54,43 @@ jobs:
github.event.client_payload.slash_command.args.named.sha
)
- name: Launch 1Password Connect instance
if: ${{ matrix.auth == 'connect' }}
if: ${{ inputs.auth == 'connect' }}
env:
OP_CONNECT_CREDENTIALS: ${{ secrets.OP_CONNECT_CREDENTIALS }}
run: |
echo "$OP_CONNECT_CREDENTIALS" > 1password-credentials.json
docker compose -f tests/fixtures/docker-compose.yml up -d && sleep 10
- name: Configure Service account
if: ${{ matrix.auth == 'service-account' }}
if: ${{ inputs.auth == 'service-account' }}
uses: ./configure
with:
service-account-token: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
- name: Verify Service Account env var is set
if: ${{ inputs.auth == 'service-account' }}
shell: bash
run: |
if [ -z "${OP_SERVICE_ACCOUNT_TOKEN}" ]; then
echo "OP_SERVICE_ACCOUNT_TOKEN environment variable is not set" >&2
exit 1
fi
- name: Configure 1Password Connect
if: ${{ matrix.auth == 'connect' }}
if: ${{ inputs.auth == 'connect' }}
uses: ./configure # 1password/load-secrets-action/configure@<version>
with:
connect-host: http://localhost:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Verify Connect env vars are set
if: ${{ inputs.auth == 'connect' }}
run: |
if [ -z "$OP_CONNECT_HOST" ] || [ -z "$OP_CONNECT_TOKEN" ]; then
echo "OP_CONNECT_HOST or OP_CONNECT_TOKEN environment variables are not set" >&2
exit 1
fi
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
version: ${{ inputs.version }}
export-env: ${{ inputs.export-env }}
env:
SECRET: ${{ inputs.secret }}

View File

@@ -14,6 +14,7 @@ jobs:
node-version: 20
- run: npm ci
- run: npm test
test-with-output-secrets:
if: |
github.ref == 'refs/heads/main' ||
@@ -23,11 +24,25 @@ jobs:
)
uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main
secrets: inherit
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [latest, latest-beta, 2.30.0, 2.30.0-beta.03]
auth: [connect, service-account]
exclude:
- os: macos-latest
auth: connect
- os: windows-latest
auth: connect
with:
os: ${{ matrix.os }}
version: ${{ matrix.version }}
auth: ${{ matrix.auth }}
secret: op://acceptance-tests/test-secret/password
secret-in-section: op://acceptance-tests/test-secret/test-section/password
multiline-secret: op://acceptance-tests/multiline-secret/notesPlain
export-env: false
test-with-export-env:
if: |
github.ref == 'refs/heads/main' ||
@@ -37,11 +52,25 @@ jobs:
)
uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main
secrets: inherit
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [latest, latest-beta, 2.30.0, 2.30.0-beta.03]
auth: [connect, service-account]
exclude:
- os: macos-latest
auth: connect
- os: windows-latest
auth: connect
with:
os: ${{ matrix.os }}
version: ${{ matrix.version }}
auth: ${{ matrix.auth }}
secret: op://acceptance-tests/test-secret/password
secret-in-section: op://acceptance-tests/test-secret/test-section/password
multiline-secret: op://acceptance-tests/multiline-secret/notesPlain
export-env: true
test-references-with-ids:
if: |
github.ref == 'refs/heads/main' ||
@@ -51,7 +80,20 @@ jobs:
)
uses: 1password/load-secrets-action/.github/workflows/acceptance-test.yml@main
secrets: inherit
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
version: [latest, latest-beta, 2.30.0, 2.30.0-beta.03]
auth: [connect, service-account]
exclude:
- os: macos-latest
auth: connect
- os: windows-latest
auth: connect
with:
os: ${{ matrix.os }}
version: ${{ matrix.version }}
auth: ${{ matrix.auth }}
secret: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
secret-in-section: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
multiline-secret: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain

View File

@@ -23,16 +23,40 @@ Read more on the [1Password Developer Portal](https://developer.1password.com/do
## ✨ Quickstart
### Export secrets as a step's output (recommended)
```yml
on: push
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Load secret
uses: 1password/load-secrets-action@v2
id: load_secret
uses: 1password/load-secrets-action@v3
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SECRET: op://app-cicd/hello-world/secret
- name: Print masked secret
run: 'echo "Secret: ${{ steps.load_secrets.outputs.SECRET }}"'
# Prints: Secret: ***
```
### Export secrets as env variables
```yml
on: push
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Load secret
uses: 1password/load-secrets-action@v3
with:
# Export loaded secrets as environment variables
export-env: true

View File

@@ -10,7 +10,10 @@ inputs:
default: "false"
export-env:
description: Export the secrets as environment variables
default: "true"
default: "false"
version:
description: Specify which 1Password CLI version to install. Defaults to "latest".
default: "latest"
runs:
using: "node20"
main: "dist/index.js"

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"

27588
configure/dist/index.js vendored Normal file

File diff suppressed because one or more lines are too long

3
configure/dist/package.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"type": "commonjs"
}

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

27
configure/index.js Normal file
View 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();

12559
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/package.json vendored
View File

@@ -1,3 +1,3 @@
{
"type": "module"
"type": "commonjs"
}

View File

@@ -1,46 +0,0 @@
#!/bin/bash
set -e
# Install op-cli
install_op_cli() {
# Create a temporary directory where the CLI is installed
OP_INSTALL_DIR="$(mktemp -d)"
if [[ ! -d "$OP_INSTALL_DIR" ]]; then
echo "Install dir $OP_INSTALL_DIR not found"
exit 1
fi
echo "::debug::OP_INSTALL_DIR: ${OP_INSTALL_DIR}"
# Get the latest stable version of the CLI
CLI_VERSION="v$(curl https://app-updates.agilebits.com/check/1/0/CLI2/en/2.0.0/N -s | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
# Get runner's architecture
ARCH=$(uname -m)
if [[ "$(getconf LONG_BIT)" = 32 ]]; then
ARCH="386"
elif [[ "$ARCH" == "x86_64" ]]; then
ARCH="amd64"
elif [[ "$ARCH" == "aarch64" ]]; then
ARCH="arm64"
fi
if [[ "$ARCH" != "386" ]] && [[ "$ARCH" != "amd64" ]] && [[ "$ARCH" != "arm" ]] && [[ "$ARCH" != "arm64" ]]; then
echo "Unsupported architecture for the 1Password CLI: $ARCH."
exit 1
fi
curl -sSfLo op.zip "https://cache.agilebits.com/dist/1P/op2/pkg/${CLI_VERSION}/op_linux_${ARCH}_${CLI_VERSION}.zip"
unzip -od "$OP_INSTALL_DIR" op.zip && rm op.zip
elif [[ "$OSTYPE" == "darwin"* ]]; then
curl -sSfLo op.pkg "https://cache.agilebits.com/dist/1P/op2/pkg/${CLI_VERSION}/op_apple_universal_${CLI_VERSION}.pkg"
pkgutil --expand op.pkg temp-pkg
tar -xvf temp-pkg/op.pkg/Payload -C "$OP_INSTALL_DIR"
rm -rf temp-pkg && rm op.pkg
else
echo "Operating system not supported yet for this GitHub Action: $OSTYPE."
exit 1
fi
}
install_op_cli

49
package-lock.json generated
View File

@@ -1,17 +1,18 @@
{
"name": "load-secrets-action",
"version": "2.0.0",
"version": "3.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "load-secrets-action",
"version": "2.0.0",
"version": "3.0.0",
"license": "MIT",
"dependencies": {
"@1password/op-js": "^0.1.11",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"op-cli-installer": "github:1Password/op-cli-installer#e6c1c758bc3339e5fe9b06255728039f688f73fa"
},
"devDependencies": {
"@1password/eslint-config": "^4.3.1",
@@ -105,6 +106,26 @@
"integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==",
"license": "MIT"
},
"node_modules/@actions/tool-cache": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
"integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/exec": "^1.0.0",
"@actions/http-client": "^2.0.1",
"@actions/io": "^1.1.1",
"semver": "^6.1.0"
}
},
"node_modules/@actions/tool-cache/node_modules/semver": {
"version": "6.3.1",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
"integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==",
"bin": {
"semver": "bin/semver.js"
}
},
"node_modules/@ampproject/remapping": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz",
@@ -6365,6 +6386,28 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/op-cli-installer": {
"version": "1.0.0",
"resolved": "git+ssh://git@github.com/1Password/op-cli-installer.git#e6c1c758bc3339e5fe9b06255728039f688f73fa",
"integrity": "sha512-ueyYQAgtbIHP2QWx9iCiztoPov01GdxPZNZ4+Qg3IaAyC4khMIk4/vYPagRhRKta+HI6fWV6jO3/ajBj27KBZA==",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/tool-cache": "^2.0.2",
"semver": "^7.7.2"
}
},
"node_modules/op-cli-installer/node_modules/semver": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
"integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==",
"bin": {
"semver": "bin/semver.js"
},
"engines": {
"node": ">=10"
}
},
"node_modules/optionator": {
"version": "0.9.4",
"resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz",

View File

@@ -1,14 +1,15 @@
{
"name": "load-secrets-action",
"version": "2.0.0",
"version": "3.0.0",
"description": "Load Secrets from 1Password",
"type": "module",
"main": "dist/index.js",
"directories": {
"test": "tests"
},
"scripts": {
"build": "ncc build ./src/index.ts",
"build:configure": "ncc build ./configure/index.js -o ./configure/dist",
"build:all": "npm run build && npm run build:configure",
"format": "prettier --ignore-path ./config/.prettierignore",
"format:check": "npm run format -- --check ./",
"format:write": "npm run format -- --write ./",
@@ -41,7 +42,8 @@
"dependencies": {
"@1password/op-js": "^0.1.11",
"@actions/core": "^1.10.1",
"@actions/exec": "^1.1.1"
"@actions/exec": "^1.1.1",
"op-cli-installer": "github:1Password/op-cli-installer#e6c1c758bc3339e5fe9b06255728039f688f73fa"
},
"devDependencies": {
"@1password/eslint-config": "^4.3.1",

View File

@@ -1,8 +1,6 @@
import path from "path";
import url from "url";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import { validateCli } from "@1password/op-js";
import { installCliOnGithubActionRunner } from "op-cli-installer";
import { loadSecrets, unsetPrevious, validateAuth } from "./utils";
const loadSecretsAction = async () => {
@@ -46,21 +44,7 @@ const installCLI = async (): Promise<void> => {
// If there's no CLI installed, then validateCli will throw an error, which we will use
// as an indicator that we need to execute the installation script.
await validateCli().catch(async () => {
const currentFile = url.fileURLToPath(import.meta.url);
const currentDir = path.dirname(currentFile);
const parentDir = path.resolve(currentDir, "..");
// Execute bash script
const cmdOut = await exec.getExecOutput(
`sh -c "` + parentDir + `/install_cli.sh"`,
);
// Add path to 1Password CLI to $PATH
const outArr = cmdOut.stdout.split("\n");
if (outArr[0] && process.env.PATH) {
const cliPath = outArr[0]?.replace(/^(::debug::OP_INSTALL_DIR: )/, "");
core.addPath(cliPath);
}
await installCliOnGithubActionRunner();
});
};