Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a7975f916 | ||
|
|
ffba2a6966 | ||
|
|
2ee4979efa | ||
|
|
7903600d82 | ||
|
|
fbf9be8f55 | ||
|
|
5a04ae581c | ||
|
|
747c0b5974 | ||
|
|
c0fbfd88d3 | ||
|
|
3f3d1e45cb | ||
|
|
b73c8a7ca6 |
16
.github/workflows/test.yml
vendored
16
.github/workflows/test.yml
vendored
@@ -15,11 +15,13 @@ jobs:
|
|||||||
- name: Configure 1Password Connect
|
- name: Configure 1Password Connect
|
||||||
uses: ./configure # 1password/load-secrets-action/configure@<version>
|
uses: ./configure # 1password/load-secrets-action/configure@<version>
|
||||||
with:
|
with:
|
||||||
connect-host: http://localhost:8080
|
connect-host: localhost:8080
|
||||||
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
|
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
|
||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
SECRET: op://acceptance-tests/test-secret/password
|
SECRET: op://acceptance-tests/test-secret/password
|
||||||
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
|
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
|
||||||
@@ -48,8 +50,6 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
with:
|
|
||||||
export-env: true
|
|
||||||
env:
|
env:
|
||||||
SECRET: op://acceptance-tests/test-secret/password
|
SECRET: op://acceptance-tests/test-secret/password
|
||||||
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
|
SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
|
||||||
@@ -80,6 +80,8 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
|
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
|
||||||
SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
|
SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
|
||||||
@@ -97,6 +99,8 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
||||||
SECRET: op://acceptance-tests/test-secret/password
|
SECRET: op://acceptance-tests/test-secret/password
|
||||||
@@ -115,8 +119,6 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
with:
|
|
||||||
export-env: true
|
|
||||||
env:
|
env:
|
||||||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
||||||
SECRET: op://acceptance-tests/test-secret/password
|
SECRET: op://acceptance-tests/test-secret/password
|
||||||
@@ -131,6 +133,8 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
||||||
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
|
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
|
||||||
@@ -149,6 +153,8 @@ jobs:
|
|||||||
- name: Load secrets
|
- name: Load secrets
|
||||||
id: load_secrets
|
id: load_secrets
|
||||||
uses: ./ # 1password/load-secrets-action@<version>
|
uses: ./ # 1password/load-secrets-action@<version>
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
|
||||||
SECRET: op://acceptance-tests/test-secret/password
|
SECRET: op://acceptance-tests/test-secret/password
|
||||||
|
|||||||
23
README.md
23
README.md
@@ -2,11 +2,24 @@
|
|||||||
|
|
||||||
This action loads secrets from 1Password into GitHub Actions using [1Password Connect](https://1password.com/secrets/).
|
This action loads secrets from 1Password into GitHub Actions using [1Password Connect](https://1password.com/secrets/).
|
||||||
|
|
||||||
Specify right from your workflow YAML which secrets from 1Password should be loaded into your job, and the action will make them available as environment variables for the next steps.
|
Specify in your workflow YAML file which secrets from 1Password should be loaded into your job, and the action will make them available as environment variables for the next steps.
|
||||||
|
|
||||||
|
Read more on the [1Password Developer Portal](https://developer.1password.com/ci-cd/github-actions).
|
||||||
|
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
Before you get started, you'll need to:
|
||||||
|
|
||||||
|
- [Deploy 1Password Connect](/docs/connect/get-started#step-2-deploy-1password-connect-server) in your infrastructure.
|
||||||
|
- Set the `OP_CONNECT_HOST` and `OP_CONNECT_TOKEN` environment variables to your Connect instance's credentials, so it'll be used to load secrets.
|
||||||
|
|
||||||
|
_Supported runners_: You can run the action on Mac and Linux runners. Windows is currently not supported.
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
You can configure the action to use either 1Password Connect instance.
|
You can configure the action to use your 1Password Connect instance.
|
||||||
|
|
||||||
If you provide `OP_CONNECT_HOST` and `OP_CONNECT_TOKEN` variables, the Connect instance will be used to load secrets. Make sure [1Password Connect](https://support.1password.com/secrets-automation/#step-2-deploy-a-1password-connect-server) is deployed in your infrastructure.
|
If you provide `OP_CONNECT_HOST` and `OP_CONNECT_TOKEN` variables, the Connect instance will be used to load secrets. Make sure [1Password Connect](https://support.1password.com/secrets-automation/#step-2-deploy-a-1password-connect-server) is deployed in your infrastructure.
|
||||||
|
|
||||||
@@ -30,6 +43,8 @@ jobs:
|
|||||||
- name: Load secret
|
- name: Load secret
|
||||||
id: op-load-secret
|
id: op-load-secret
|
||||||
uses: 1password/load-secrets-action@v1
|
uses: 1password/load-secrets-action@v1
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
OP_CONNECT_HOST: <Your Connect instance URL>
|
OP_CONNECT_HOST: <Your Connect instance URL>
|
||||||
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
|
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
|
||||||
@@ -64,6 +79,8 @@ jobs:
|
|||||||
- name: Load Docker credentials
|
- name: Load Docker credentials
|
||||||
id: load-docker-credentials
|
id: load-docker-credentials
|
||||||
uses: 1password/load-secrets-action@v1
|
uses: 1password/load-secrets-action@v1
|
||||||
|
with:
|
||||||
|
export-env: false
|
||||||
env:
|
env:
|
||||||
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
|
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
|
||||||
DOCKERHUB_USERNAME: op://app-cicd/docker/username
|
DOCKERHUB_USERNAME: op://app-cicd/docker/username
|
||||||
@@ -181,7 +198,7 @@ jobs:
|
|||||||
|
|
||||||
| Name | Default | Description |
|
| Name | Default | Description |
|
||||||
| ---------------- | ------- | ---------------------------------------------------------------------------------- |
|
| ---------------- | ------- | ---------------------------------------------------------------------------------- |
|
||||||
| `export-env` | `false` | Export the loaded secrets as environment variables |
|
| `export-env` | `true` | Export the loaded secrets as environment variables |
|
||||||
| `unset-previous` | `false` | Whether to unset environment variables populated by 1Password in earlier job steps |
|
| `unset-previous` | `false` | Whether to unset environment variables populated by 1Password in earlier job steps |
|
||||||
|
|
||||||
## Secrets Reference Syntax
|
## Secrets Reference Syntax
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ inputs:
|
|||||||
default: false
|
default: false
|
||||||
export-env:
|
export-env:
|
||||||
description: Export the secrets as environment variables
|
description: Export the secrets as environment variables
|
||||||
default: false
|
default: true
|
||||||
runs:
|
runs:
|
||||||
using: 'node16'
|
using: 'node16'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
@@ -2,6 +2,11 @@
|
|||||||
# shellcheck disable=SC2046,SC2001,SC2086
|
# shellcheck disable=SC2046,SC2001,SC2086
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Pass User-Agent Inforomation to the 1Password CLI
|
||||||
|
export OP_INTEGRATION_NAME="1Password GitHub Action"
|
||||||
|
export OP_INTEGRATION_ID="GHA"
|
||||||
|
export OP_INTEGRATION_BUILDNUMBER="1010001"
|
||||||
|
|
||||||
readonly CONNECT="CONNECT"
|
readonly CONNECT="CONNECT"
|
||||||
readonly SERVICE_ACCOUNT="SERVICE_ACCOUNT"
|
readonly SERVICE_ACCOUNT="SERVICE_ACCOUNT"
|
||||||
|
|
||||||
@@ -9,6 +14,10 @@ auth_type=$CONNECT
|
|||||||
managed_variables_var="OP_MANAGED_VARIABLES"
|
managed_variables_var="OP_MANAGED_VARIABLES"
|
||||||
IFS=','
|
IFS=','
|
||||||
|
|
||||||
|
if [[ "$OP_CONNECT_HOST" != "http://"* ]] && [[ "$OP_CONNECT_HOST" != "https://"* ]]; then
|
||||||
|
export OP_CONNECT_HOST="http://"$OP_CONNECT_HOST
|
||||||
|
fi
|
||||||
|
|
||||||
# Unset all secrets managed by 1Password if `unset-previous` is set.
|
# Unset all secrets managed by 1Password if `unset-previous` is set.
|
||||||
unset_prev_secrets() {
|
unset_prev_secrets() {
|
||||||
if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then
|
if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then
|
||||||
@@ -31,10 +40,10 @@ unset_prev_secrets() {
|
|||||||
# Install op-cli
|
# Install op-cli
|
||||||
install_op_cli() {
|
install_op_cli() {
|
||||||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
||||||
curl -sSfLo op.zip "https://cache.agilebits.com/dist/1P/op2/pkg/v2.7.1-beta.01/op_linux_amd64_v2.7.1-beta.01.zip"
|
curl -sSfLo op.zip "https://cache.agilebits.com/dist/1P/op2/pkg/v2.10.0-beta.02/op_linux_amd64_v2.10.0-beta.02.zip"
|
||||||
unzip -od /usr/local/bin/ op.zip && rm op.zip
|
unzip -od /usr/local/bin/ op.zip && rm op.zip
|
||||||
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
curl -sSfLo op.pkg "https://cache.agilebits.com/dist/1P/op2/pkg/v2.7.1-beta.01/op_apple_universal_v2.7.1-beta.01.pkg"
|
curl -sSfLo op.pkg "https://cache.agilebits.com/dist/1P/op2/pkg/v2.10.0-beta.02/op_apple_universal_v2.10.0-beta.02.pkg"
|
||||||
sudo installer -pkg op.pkg -target /usr/local/bin/ && rm op.pkg
|
sudo installer -pkg op.pkg -target /usr/local/bin/ && rm op.pkg
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -43,7 +52,7 @@ populating_secret() {
|
|||||||
ref=$(printenv $1)
|
ref=$(printenv $1)
|
||||||
|
|
||||||
echo "Populating variable: $1"
|
echo "Populating variable: $1"
|
||||||
secret_value=$(op read $ref)
|
secret_value=$(op read "$ref")
|
||||||
|
|
||||||
if [ -z "$secret_value" ]; then
|
if [ -z "$secret_value" ]; then
|
||||||
echo "Could not find or access secret $ref"
|
echo "Could not find or access secret $ref"
|
||||||
@@ -67,7 +76,7 @@ populating_secret() {
|
|||||||
# To support multiline secrets, we'll use the heredoc syntax to populate the environment variables.
|
# To support multiline secrets, we'll use the heredoc syntax to populate the environment variables.
|
||||||
# As the heredoc identifier, we'll use a randomly generated 64-character string,
|
# As the heredoc identifier, we'll use a randomly generated 64-character string,
|
||||||
# so that collisions are practically impossible.
|
# so that collisions are practically impossible.
|
||||||
random_heredoc_identifier=$(openssl rand -hex 16)
|
random_heredoc_identifier=$(openssl rand -hex 32)
|
||||||
|
|
||||||
{
|
{
|
||||||
# Populate env var, using heredoc syntax with generated identifier
|
# Populate env var, using heredoc syntax with generated identifier
|
||||||
|
|||||||
Reference in New Issue
Block a user