Compare commits

..

71 Commits

Author SHA1 Message Date
Eduard Filip
0a7975f916 Ensure that the action is backwards-compatible (#25)
Some checks failed
Run acceptance tests / use-connect-without-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-references-with-id (push) Has been cancelled
Run acceptance tests / use-service-account-without-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-references-with-id (push) Has been cancelled
Run acceptance tests / run-on-macos-12 (push) Has been cancelled
Bring 2 changes that ensure that the GitHub Action is backwards compatible:

- Append `http://` if the prefix is not provided in the `OP_CONNECT_HOST` (this is caused by the fact that `curl` guesses the protocol if not provided (https://linux.die.net/man/1/curl), which we missed when switching to using the 1Password CLI as the backend of the action)
- Set the default of export-env to true, since that was the default behavior of the action until we added the possibility to export secrets as step's output.

Also, the documentation is adjusted to reflect these changes.
2022-12-22 12:46:28 +02:00
volodymyrZotov
ffba2a6966 Merge pull request #21 from simonwhitaker/simon/quote-ref
Some checks failed
Run acceptance tests / use-connect-without-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-references-with-id (push) Has been cancelled
Run acceptance tests / use-service-account-without-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-references-with-id (push) Has been cancelled
Run acceptance tests / run-on-macos-12 (push) Has been cancelled
Quote $ref to avoid word splitting
2022-12-16 16:44:11 +02:00
Simon Whitaker
2ee4979efa Quote $ref to avoid word splitting 2022-12-16 14:40:27 +00:00
Eduard Filip
7903600d82 Merge pull request #22 from 1Password/feat/user-agent-info
Some checks failed
Run acceptance tests / use-connect-without-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-references-with-id (push) Has been cancelled
Run acceptance tests / use-service-account-without-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-references-with-id (push) Has been cancelled
Run acceptance tests / run-on-macos-12 (push) Has been cancelled
Pass User-Agent Information to the 1Password CLI
2022-12-14 17:19:34 +01:00
Eddy Filip
fbf9be8f55 Pass User-Agent Information to the 1Password CLI 2022-12-14 14:57:06 +02:00
Eddy Filip
5a04ae581c Update 1Password CLI to the latest version 2022-12-14 14:49:33 +02:00
Eduard Filip
747c0b5974 Merge pull request #19 from 1Password/ekmoore-readme-update
Add link to README
2022-12-07 07:40:25 +01:00
Erin Moore
c0fbfd88d3 Added link to developer.1password.com
Added link to GitHub Actions article on https://developer.1password.com/ci-cd/github-actions
2022-12-06 13:57:18 -05:00
Eduard Filip
3f3d1e45cb Merge pull request #18 from 1Password/eddy/rand-64
Make openssl generate a 64-character string as mentioned in comment
2022-10-17 19:03:05 +02:00
Eddy Filip
b73c8a7ca6 Make openssl generate a 64-character string as mentioned in comment 2022-10-17 18:22:43 +02:00
Jillian W
da6de9b6b3 Merge pull request #16 from 1Password/remove-service-account-docs
Some checks failed
Run acceptance tests / use-connect-without-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-export-env (push) Has been cancelled
Run acceptance tests / use-connect-with-references-with-id (push) Has been cancelled
Run acceptance tests / use-service-account-without-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-export-env (push) Has been cancelled
Run acceptance tests / use-service-account-with-references-with-id (push) Has been cancelled
Run acceptance tests / run-on-macos-12 (push) Has been cancelled
Removing mention of service accounts from the readme documentation
2022-09-07 15:39:32 -03:00
jillianwilson
7610c5737f Remoning mention of service accounts from the readme documentation 2022-09-07 15:16:27 -03:00
Eduard Filip
30b5930e91 Merge pull request #15 from 1Password/update-package-lock
Update package-lock.json
2022-08-31 18:47:22 +02:00
Eddy Filip
c2c5cda6a2 Update package-lock.json 2022-08-31 18:39:52 +02:00
Eduard Filip
351ed34750 Merge pull request #14 from 1Password/update-dependencies
Update package dependencies
2022-08-31 15:07:41 +02:00
Eddy Filip
be04d82018 Update package dependencies 2022-08-31 12:03:43 +02:00
volodymyrZotov
8c15b6c54d Merge pull request #5 from 1Password/feature/add-cli
Add the op CLI in the script
2022-08-30 10:53:31 +03:00
volodymyrZotov
cb83ae04bf improved readme 2022-08-30 10:51:22 +03:00
volodymyrZotov
e3b137e007 added macos test case 2022-08-19 14:02:58 +03:00
volodymyrZotov
30def81a24 added macos installer reference 2022-08-19 14:01:55 +03:00
volodymyrZotov
ed1f9a48af use op cli to fetch secrets for connect 2022-08-19 14:00:33 +03:00
volodymyrZotov
b1b82d7384 updated gitignore 2022-08-19 11:48:08 +03:00
volodymyrZotov
a37c95c8d0 Merge branch 'feature/add-cli' of github.com:1Password/load-secrets-action into feature/add-cli 2022-08-17 18:07:40 +03:00
volodymyrZotov
aaee1916c6 updated README 2022-08-17 18:07:07 +03:00
Eddy Filip
c53c263a7e Add service account token in env
It was accidentally removed
2022-08-16 14:05:33 +01:00
Eddy Filip
7d858c7ad5 Make dedicated tests for secret references with IDs
The item and vault IDs are changed as well.
2022-08-16 13:38:07 +01:00
volodymyrZotov
ce8b31d0b9 added more secrets to test 2022-08-15 18:21:18 +03:00
volodymyrZotov
2ac8886444 fixed multiline secret ref 2022-08-15 18:18:33 +03:00
volodymyrZotov
641b0d93ec use ids for multiline secret 2022-08-15 18:14:55 +03:00
volodymyrZotov
c27a045581 use references that has ids instead of names 2022-08-15 17:22:28 +03:00
volodymyrZotov
953b51736f extract op to proper path 2022-08-15 17:20:19 +03:00
volodymyrZotov
2f338e16af use node16 2022-08-15 14:33:11 +03:00
volodymyrZotov
e9bd76c87a removed test-connect-export case 2022-08-15 14:33:00 +03:00
volodymyrZotov
d5280efa32 updated README.md 2022-08-15 14:17:50 +03:00
volodymyrZotov
8d99fc2a1e properly unpack tar.gz 2022-08-15 14:17:44 +03:00
volodymyrZotov
5c5bbcbaf0 prevent command injection vulnerability 2022-08-15 13:32:42 +03:00
volodymyrZotov
e1b37a5b1e updated README and configuration.yml 2022-08-11 18:58:35 +03:00
volodymyrZotov
2a214a29d3 unset IFS at the end of the flow 2022-08-11 18:38:45 +03:00
volodymyrZotov
2a4f64c09d Merge branch 'feature/add-cli' of github.com:1Password/load-secrets-action into feature/add-cli 2022-08-11 18:35:38 +03:00
volodymyrZotov
df0b228eb9 removed logs to console 2022-08-11 18:33:04 +03:00
volodymyrZotov
8052f86fc6 added additional test cases 2022-08-11 18:32:47 +03:00
volodymyrZotov
34bed60a89 use op read to retrive item values 2022-08-11 18:08:26 +03:00
volodymyrZotov
ada03a0325 use cli to retrieve secrets if signed in via connect 2022-08-11 16:39:39 +03:00
volodymyrZotov
c7774c7068 updated darwin link 2022-08-10 17:02:15 +03:00
volodymyrZotov
1263fc888c updated darwin op archive link 2022-08-10 16:57:06 +03:00
volodymyrZotov
858b6a838e added env variables to test secret section 2022-08-10 12:59:29 +03:00
volodymyrZotov
b38b493d73 rename tests 2022-08-10 11:45:24 +03:00
volodymyrZotov
bb28cdf0c6 added test case for load secrets via op cli 2022-08-10 11:44:12 +03:00
volodymyrZotov
302881bfef use correct op cli version fo linux 2022-08-10 11:42:31 +03:00
volodymyrZotov
9fdfd04a6f revert back test change 2022-08-10 10:34:38 +03:00
volodymyrZotov
b38d01591f test should fail cause not existing field provided 2022-08-10 10:33:04 +03:00
volodymyrZotov
d78889ad20 updated test.yml 2022-08-10 10:26:19 +03:00
volodymyrZotov
6c02b8909f updated configure script 2022-08-10 10:23:14 +03:00
volodymyrZotov
cb24269fc9 Merge branch 'main' into feature/add-cli
# Conflicts:
#	action.yml
2022-08-09 16:57:20 +03:00
volodymyrZotov
300c776a97 revert logic to fetch items using connect 2022-08-09 12:06:45 +03:00
volodymyrZotov
2faffa0507 split logic for connect and service_account flows 2022-08-09 11:21:49 +03:00
Eduard Filip
d50df7cd6d Merge pull request #11 from 1Password/eddy/fix-injection
Some checks failed
Run acceptance tests / test (push) Has been cancelled
Improve the way input is processed to avoid command injection
2022-05-18 17:42:36 +02:00
Eddy Filip
a5debe1b2e Improve the way input is processed to avoid command injection 2022-05-18 12:47:49 +03:00
Eddy Filip
da5dd0865d Add newline to trigger pipeline 2021-10-05 16:34:31 +02:00
Eddy Filip
4af3346b6a Update README with new functionality
Give examples for both ways of loading secrets. Update masking. Add security and help sections.
2021-09-06 12:39:46 +03:00
Eduard Filip
fae9e58c4f Merge pull request #7 from 1Password/feature/output-secrets
Enable using loaded secrets from step's output
2021-09-02 10:45:20 +02:00
Eddy Filip
000522e32f Adjust package dependencies and add newlines 2021-09-01 20:09:34 +02:00
Eddy Filip
4baca64066 Enable using loaded secrets from step's output 2021-09-01 18:23:35 +02:00
Eddy Filip
ac12d2e3c4 Switch to node action
This is done to be able to pass loaded secrets as output. This is not available with a composite action, unless we hard-code the action's outputs, which is not a desired outcome.
2021-09-01 18:20:57 +02:00
Eddy Filip
e8da10d005 Use op cli alpha v2 2021-09-01 16:20:47 +02:00
Eddy Filip
5add51bcb8 Change to new command signature
The command is changed from `op list envars` to `op env ls`
2021-08-16 17:17:20 +02:00
Eddy Filip
08df44393f Remove surrounding $() 2021-08-03 19:24:26 +02:00
Eddy Filip
478705935c Fix lint 2021-08-03 19:17:32 +02:00
Eddy Filip
e64093d691 Add the op-cli in the script
By adding the `op-cli` in the script, we no longer need to look for environment variables that have a reference and fetch the values of the secrets through shell script. Instead, we use the commands `op list envars` and `op read` (alpha version)
2021-08-03 18:00:57 +02:00
Floris van der Grinten
e28960dbbb Merge pull request #4 from 1Password/item-and-vault-names
Some checks failed
Run acceptance tests / test (push) Has been cancelled
2021-06-09 14:48:31 +02:00
Floris van der Grinten
8d95cf6d0d Fix item and vault loading by name 2021-06-09 12:41:01 +02:00
12 changed files with 2578 additions and 157 deletions

View File

@@ -2,7 +2,37 @@ on: push
name: Run acceptance tests name: Run acceptance tests
jobs: jobs:
test: use-connect-without-export-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Launch 1Password Connect instance
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 1Password Connect
uses: ./configure # 1password/load-secrets-action/configure@<version>
with:
connect-host: localhost:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
export-env: false
env:
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
- name: Assert test secret values
env:
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh
use-connect-with-export-env:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@@ -18,34 +48,121 @@ jobs:
connect-host: http://localhost:8080 connect-host: http://localhost:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }} connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load secrets - name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version> uses: ./ # 1password/load-secrets-action@<version>
env: env:
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password SECRET: op://acceptance-tests/test-secret/password
SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/test-section/password SECRET_IN_SECTION: op://acceptance-tests/test-secret/test-section/password
UNMASKED_VALUE: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/test-section/username MULTILINE_SECRET: op://acceptance-tests/multiline-secret/notesPlain
- name: Load multiline secret
uses: ./ # 1password/load-secrets-action@<version>
env:
MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain
- name: Print environment variables with masked secrets
run: printenv
- name: Assert test secret values - name: Assert test secret values
run: ./tests/assert-env-set.sh run: ./tests/assert-env-set.sh
- name: Remove secrets - name: Remove secrets
uses: ./ # 1password/load-secrets-action@<version> uses: ./ # 1password/load-secrets-action@<version>
with: with:
unset-previous: true unset-previous: true
- name: Print environment variables with secrets removed
run: printenv
- name: Assert removed secrets - name: Assert removed secrets
run: ./tests/assert-env-unset.sh run: ./tests/assert-env-unset.sh
- name: Load secret again use-connect-with-references-with-id:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Launch 1Password Connect instance
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 1Password Connect
uses: ./configure # 1password/load-secrets-action/configure@<version>
with:
connect-host: http://localhost:8080
connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: 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/test-section/password SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain
- name: Print environment variables with masked secrets - name: Assert test secret values
run: printenv env:
- name: Assert test secret values again SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh
use-service-account-without-export-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
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
- name: Assert test secret values
env:
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh
use-service-account-with-export-env:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
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
- name: Assert test secret values
run: ./tests/assert-env-set.sh
use-service-account-with-references-with-id:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/password
SECRET_IN_SECTION: op://v5pz6venw4roosmkzdq2nhpv6u/hrgkzhrlvscomepxlgafb2m3ca/Section_tco6nsqycj6jcbyx63h5isxcny/doxu3mhkozcznnk5vjrkpdqayy
MULTILINE_SECRET: op://v5pz6venw4roosmkzdq2nhpv6u/ghtz3jvcc6dqmzc53d3r3eskge/notesPlain
- name: Assert test secret values
env:
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh
run-on-macos-12:
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Load secrets
id: load_secrets
uses: ./ # 1password/load-secrets-action@<version>
with:
export-env: false
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
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
- name: Assert test secret values
env:
SECRET: ${{ steps.load_secrets.outputs.SECRET }}
SECRET_IN_SECTION: ${{ steps.load_secrets.outputs.SECRET_IN_SECTION }}
MULTILINE_SECRET: ${{ steps.load_secrets.outputs.MULTILINE_SECRET }}
run: ./tests/assert-env-set.sh run: ./tests/assert-env-set.sh

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
node_modules/

151
README.md
View File

@@ -1,11 +1,110 @@
# Load Secrets from 1Password - GitHub Action # Load Secrets from 1Password - GitHub Action
The action to load secrets from [1Password Connect](https://1password.com/secrets/) into GitHub Actions. This action loads secrets from 1Password into GitHub Actions using [1Password Connect](https://1password.com/secrets/).
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.
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.
## Usage ## Usage
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.
There are two ways that secrets can be loaded:
- [use the secrets from the action's ouput](#use-secrets-from-the-actions-output)
- [export secrets as environment variables](#export-secrets-as-environment-variables)
### Use secrets from the action's output
This method allows for you to use the loaded secrets as an output from the step: `steps.step-id.outputs.secret-name`. You will need to set an id for the step that uses this action to be able to access its outputs. For more details, , see [`outputs.<output_id>`](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#outputsoutput_id).
```yml
on: push
jobs:
hello-world:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Load secret
id: op-load-secret
uses: 1password/load-secrets-action@v1
with:
export-env: false
env:
OP_CONNECT_HOST: <Your Connect instance URL>
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
SECRET: op://app-cicd/hello-world/secret
- name: Print masked secret
run: echo "Secret: ${{ steps.op-load-secret.outputs.SECRET }}"
# Prints: Secret: ***
```
<details>
<summary><b>Longer usage example</b></summary>
```yml
on: push
name: Deploy app
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Configure 1Password Connect
uses: 1password/load-secrets-action/configure@v1
with:
# Persist the 1Password Connect URL for next steps. You can also persist
# the Connect token using input `connect-token`, but keep in mind that
# every single step in the job would then be able to access the token.
connect-host: https://1password.acme.com
- name: Load Docker credentials
id: load-docker-credentials
uses: 1password/load-secrets-action@v1
with:
export-env: false
env:
OP_CONNECT_TOKEN: ${{ secrets.OP_CONNECT_TOKEN }}
DOCKERHUB_USERNAME: op://app-cicd/docker/username
DOCKERHUB_TOKEN: op://app-cicd/docker/token
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ steps.load-docker-credentials.outputs.DOCKERHUB_USERNAME }}
password: ${{ steps.load-docker-credentials.outputs.DOCKERHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
push: true
tags: acme/app:latest
```
</details>
### Export secrets as environment variables
This method, allows the action to access the loaded secrets as environment variables. These environment variables are accessible at a job level.
```yml ```yml
on: push on: push
jobs: jobs:
@@ -16,6 +115,9 @@ jobs:
- name: Load secret - name: Load secret
uses: 1password/load-secrets-action@v1 uses: 1password/load-secrets-action@v1
with:
# Export loaded secrets as environment variables
export-env: true
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 }}
@@ -25,6 +127,7 @@ jobs:
run: echo "Secret: $SECRET" run: echo "Secret: $SECRET"
# Prints: Secret: *** # Prints: Secret: ***
``` ```
<details> <details>
<summary><b>Longer usage example</b></summary> <summary><b>Longer usage example</b></summary>
@@ -48,6 +151,9 @@ jobs:
- name: Load Docker credentials - name: Load Docker credentials
uses: 1password/load-secrets-action@v1 uses: 1password/load-secrets-action@v1
with:
# Export loaded secrets as environment variables
export-env: true
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
@@ -71,6 +177,8 @@ jobs:
- name: Load AWS credentials - name: Load AWS credentials
uses: 1password/load-secrets-action@v1 uses: 1password/load-secrets-action@v1
with: with:
# Export loaded secrets as environment variables
export-env: true
# Remove local copies of the Docker credentials, which are not needed anymore # Remove local copies of the Docker credentials, which are not needed anymore
unset-previous: true unset-previous: true
env: env:
@@ -83,12 +191,14 @@ jobs:
# done automatically by the step above # done automatically by the step above
run: ./deploy.sh run: ./deploy.sh
``` ```
</details> </details>
## Action Inputs ## Action Inputs
| Name | Default | Description | | Name | Default | Description |
|---|---|---| | ---------------- | ------- | ---------------------------------------------------------------------------------- |
| `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
@@ -100,23 +210,21 @@ These reference URIs have the following syntax:
> `op://<vault>/<item>[/<section>]/<field>` > `op://<vault>/<item>[/<section>]/<field>`
So for example, the reference URI `op://app-cicd/aws/secret-access-key` would be interpreted as: So for example, the reference URI `op://app-cicd/aws/secret-access-key` would be interpreted as:
* **Vault:** `app-cicd`
* **Item:** `aws` - **Vault:** `app-cicd`
* **Section:** default section - **Item:** `aws`
* **Field:** `secret-access-key` - **Section:** default section
- **Field:** `secret-access-key`
## Masking ## Masking
Similar to regular GitHub repository secrets, secret fields from 1Password will automatically be masked from the GitHub Actions logs too. Similar to regular GitHub repository secrets, fields from 1Password will automatically be masked from the GitHub Actions logs too.
A 1Password field is considered 'secret' when it's marked as concealed (which shows as `•••••••` in the 1Password GUI) or when it's a secure note.
So if one of these values accidentally gets printed, it'll get replaced with `***`. So if one of these values accidentally gets printed, it'll get replaced with `***`.
This means that a username or port field for example will not get masked. ## 1Password Configuration
## 1Password Connect Configuration To use the action with Connect, you need to have a [1Password Connect](https://support.1password.com/secrets-automation/#step-1-set-up-a-secrets-automation-workflow) instance deployed somewhere.
To configure the action with your Connect host and token, set the `OP_CONNECT_HOST` and `OP_CONNECT_TOKEN` environment variables.
To use the action, you need to have a [1Password Connect](https://support.1password.com/secrets-automation/#step-1-set-up-a-secrets-automation-workflow) instance deployed somewhere.
To configure the action with your Connect URL and a Connect token, you can set the `OP_CONNECT_HOST` and `OP_CONNECT_TOKEN` variables.
If you're using the `load-secrets` action more than once in a single job, you can use the `configure` action to avoid duplicate configuration: If you're using the `load-secrets` action more than once in a single job, you can use the `configure` action to avoid duplicate configuration:
@@ -133,7 +241,6 @@ jobs:
with: with:
connect-host: <Your Connect instance URL> connect-host: <Your Connect instance URL>
connect-token: ${{ secrets.OP_CONNECT_TOKEN }} connect-token: ${{ secrets.OP_CONNECT_TOKEN }}
- name: Load secret - name: Load secret
uses: 1password/load-secrets-action@v1 uses: 1password/load-secrets-action@v1
env: env:
@@ -143,10 +250,22 @@ jobs:
### `configure` Action Inputs ### `configure` Action Inputs
| Name | Default | Environment variable | Description | | Name | Default | Environment variable | Description |
|---|---|---|---| | ----------------------- | ------- | -------------------------- | -------------------------------------------------------- |
| `connect-host` | | `OP_CONNECT_HOST` | Your 1Password Connect instance URL | | `connect-host` | | `OP_CONNECT_HOST` | Your 1Password Connect instance URL |
| `connect-token` | | `OP_CONNECT_TOKEN` | Token to authenticate to your 1Password Connect instance | | `connect-token` | | `OP_CONNECT_TOKEN` | Token to authenticate to your 1Password Connect instance |
## Supported Runners ## Supported Runners
You can run the action on Linux and macOS runners. Windows is currently not supported. You can run the action on Linux and macOS runners. Windows is currently not supported.
## Security
1Password requests you practice responsible disclosure if you discover a vulnerability.
Please file requests via [**BugCrowd**](https://bugcrowd.com/agilebits).
For information about security practices, please visit our [Security homepage](https://bugcrowd.com/agilebits).
## Getting help
If you find yourself stuck, visit our [**Support Page**](https://support.1password.com/) for help.

View File

@@ -8,10 +8,9 @@ inputs:
unset-previous: unset-previous:
description: Whether to unset environment variables populated by 1Password in earlier job steps description: Whether to unset environment variables populated by 1Password in earlier job steps
default: false default: false
export-env:
description: Export the secrets as environment variables
default: true
runs: runs:
using: composite using: 'node16'
steps: main: 'dist/index.js'
- run: |
export INPUT_UNSET_PREVIOUS=${{ inputs.unset-previous }}
${{ github.action_path }}/entrypoint.sh
shell: bash

View File

@@ -1,16 +1,20 @@
name: Configure 1Password Connect name: Configure 1Password Connect and service account
description: Persist 1Password Connect host and token for use in next steps. description: Persist 1Password Connect host, token and service account for use in next steps.
author: 1Password author: 1Password
inputs: inputs:
connect-host: connect-host:
description: Your 1Password Connect instance URL description: Your 1Password Connect instance URL
connect-token: connect-token:
description: Token to authenticate to your 1Password Connect instance description: Token to authenticate to your 1Password Connect instance
service-account-token:
description: Your 1Password service account token
runs: runs:
using: composite using: composite
steps: steps:
- run: | - shell: bash
export INPUT_CONNECT_HOST=${{ inputs.connect-host }} env:
export INPUT_CONNECT_TOKEN=${{ inputs.connect-token }} 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 ${{ github.action_path }}/entrypoint.sh
shell: bash

View File

@@ -14,3 +14,8 @@ OP_CONNECT_TOKEN="${INPUT_CONNECT_TOKEN:-$OP_CONNECT_TOKEN}"
if [ -n "$OP_CONNECT_TOKEN" ]; then if [ -n "$OP_CONNECT_TOKEN" ]; then
echo "OP_CONNECT_TOKEN=$OP_CONNECT_TOKEN" >> $GITHUB_ENV echo "OP_CONNECT_TOKEN=$OP_CONNECT_TOKEN" >> $GITHUB_ENV
fi 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

1954
dist/index.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -2,15 +2,24 @@
# shellcheck disable=SC2046,SC2001,SC2086 # shellcheck disable=SC2046,SC2001,SC2086
set -e set -e
if [ -z "$OP_CONNECT_TOKEN" ] || [ -z "$OP_CONNECT_HOST" ]; then # Pass User-Agent Inforomation to the 1Password CLI
echo "\$OP_CONNECT_TOKEN and \$OP_CONNECT_HOST must be set" export OP_INTEGRATION_NAME="1Password GitHub Action"
exit 1 export OP_INTEGRATION_ID="GHA"
export OP_INTEGRATION_BUILDNUMBER="1010001"
readonly CONNECT="CONNECT"
readonly SERVICE_ACCOUNT="SERVICE_ACCOUNT"
auth_type=$CONNECT
managed_variables_var="OP_MANAGED_VARIABLES"
IFS=','
if [[ "$OP_CONNECT_HOST" != "http://"* ]] && [[ "$OP_CONNECT_HOST" != "https://"* ]]; then
export OP_CONNECT_HOST="http://"$OP_CONNECT_HOST
fi fi
managed_variables_var="OP_MANAGED_VARIABLES"
IFS=',' read -r -a managed_variables <<< "$(printenv $managed_variables_var)"
# 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() {
if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then
echo "Unsetting previous values..." echo "Unsetting previous values..."
@@ -26,79 +35,31 @@ if [ "$INPUT_UNSET_PREVIOUS" == "true" ]; then
managed_variables=() managed_variables=()
fi fi
}
# Iterate over environment varables to find 1Password references, load the secret values, # Install op-cli
# and make them available as environment variables in the next steps. install_op_cli() {
IFS=$'\n' if [[ "$OSTYPE" == "linux-gnu"* ]]; then
for possible_ref in $(printenv | grep "=op://" | grep -v "^#"); do 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"
env_var=$(echo "$possible_ref" | cut -d '=' -f1) unzip -od /usr/local/bin/ op.zip && rm op.zip
ref=$(printenv $env_var) elif [[ "$OSTYPE" == "darwin"* ]]; then
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"
if [[ ! $ref == "op://"* ]]; then sudo installer -pkg op.pkg -target /usr/local/bin/ && rm op.pkg
echo "Not really a reference: $ref"
continue
fi fi
}
path=$(echo $ref | sed -e "s/^op:\/\///") populating_secret() {
if [ $(echo "$path" | tr -cd '/' | wc -c) -lt 2 ]; then ref=$(printenv $1)
echo "Expected path to be in format op://<vault>/<item>[/<section>]/<field>: $ref"
continue
fi
echo "Populating variable: $env_var" echo "Populating variable: $1"
secret_value=$(op read "$ref")
vault=""
item=""
section=""
field=""
i=0
IFS="/"
for component in $path; do
((i+=1))
case "$i" in
1) vault=$component ;;
2) item=$component ;;
3) section=$component ;;
4) field=$component ;;
esac
done
unset IFS
# If field is not set, it may have wrongfully been interpreted as the section.
if [ -z "$field" ]; then
field="$section"
section=""
fi
echo "Loading item $item from vault $vault..."
item_json=$(curl -sSf -H "Content-Type: application/json" -H "Authorization: Bearer $OP_CONNECT_TOKEN" "$OP_CONNECT_HOST/v1/vaults/$vault/items/$item")
jq_field_selector=".id == \"$field\" or .label == \"$field\""
jq_section_selector=".section == null"
# If the reference contains a section, edit the jq selector to take that into account.
if [ -n "$section" ]; then
echo "Looking for section: $section"
section_id=$(echo "$item_json" | jq -r ".sections[] | select(.id == \"$section\" or .label == \"$section\") | .id")
jq_section_selector=".section.id == \"$section_id\""
fi
jq_secret_selector="$jq_section_selector and ($jq_field_selector)"
echo "Looking for field: $field"
secret_field_json=$(echo "$item_json" | jq -r "first(.fields[] | select($jq_secret_selector))")
field_type=$(echo "$secret_field_json" | jq -r '.type')
field_purpose=$(echo "$secret_field_json" | jq -r '.purpose')
secret_value=$(echo "$secret_field_json" | jq -r '.value')
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"
exit 1 exit 1
fi fi
# If the field is marked as concealed or is a note, register a mask # Register a mask for the secret to prevent accidental log exposure.
# for the secret to prevent accidental log exposure.
if [ "$field_type" == "CONCEALED" ] || [ "$field_purpose" == "NOTES" ]; then
# To support multiline secrets, escape percent signs and add a mask per line. # To support multiline secrets, escape percent signs and add a mask per line.
escaped_mask_value=$(echo "$secret_value" | sed -e 's/%/%25/g') escaped_mask_value=$(echo "$secret_value" | sed -e 's/%/%25/g')
IFS=$'\n' IFS=$'\n'
@@ -110,12 +71,12 @@ for possible_ref in $(printenv | grep "=op://" | grep -v "^#"); do
echo "::add-mask::$line" echo "::add-mask::$line"
done done
unset IFS unset IFS
fi
if [ "$INPUT_EXPORT_ENV" == "true" ]; then
# 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
@@ -123,11 +84,45 @@ for possible_ref in $(printenv | grep "=op://" | grep -v "^#"); do
echo "$secret_value" echo "$secret_value"
echo "${random_heredoc_identifier}" echo "${random_heredoc_identifier}"
} >> $GITHUB_ENV } >> $GITHUB_ENV
echo "GITHUB_ENV: $(cat $GITHUB_ENV)"
else
# Prepare the secret_value to be outputed properly (especially multiline secrets)
secret_value=$(echo "$secret_value" | awk -v ORS='%0A' '1')
echo "::set-output name=$env_var::$secret_value"
fi
managed_variables+=("$env_var") managed_variables+=("$env_var")
done }
unset IFS
# Load environment variables using op cli. Iterate over them to find 1Password references, load the secret values,
# and make them available as environment variables in the next steps.
extract_secrets() {
IFS=$'\n'
for env_var in $(op env ls); do
populating_secret $env_var
done
}
read -r -a managed_variables <<< "$(printenv $managed_variables_var)"
if [ -z "$OP_CONNECT_TOKEN" ] || [ -z "$OP_CONNECT_HOST" ]; then
if [ -z "$OP_SERVICE_ACCOUNT_TOKEN" ]; then
echo "(\$OP_CONNECT_TOKEN and \$OP_CONNECT_HOST) or \$OP_SERVICE_ACCOUNT_TOKEN must be set"
exit 1
fi
auth_type=$SERVICE_ACCOUNT
fi
printf "Authenticated with %s \n" $auth_type
unset_prev_secrets
install_op_cli
extract_secrets
unset IFS
# Add extra env var that lists which secrets are managed by 1Password so that in a later step # Add extra env var that lists which secrets are managed by 1Password so that in a later step
# these can be unset again. # these can be unset again.
managed_variables_str=$(IFS=','; echo "${managed_variables[*]}") managed_variables_str=$(IFS=','; echo "${managed_variables[*]}")

156
package-lock.json generated Normal file
View File

@@ -0,0 +1,156 @@
{
"name": "load-secrets-action",
"version": "1.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "load-secrets-action",
"version": "1.1.0",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/exec": "^1.1.1"
},
"devDependencies": {
"@types/node": "^18.7.14",
"@vercel/ncc": "^0.34.0",
"typescript": "^4.8.2"
}
},
"node_modules/@actions/core": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
"dependencies": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"node_modules/@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"dependencies": {
"@actions/io": "^1.0.1"
}
},
"node_modules/@actions/http-client": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
"dependencies": {
"tunnel": "^0.0.6"
}
},
"node_modules/@actions/io": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.1.tgz",
"integrity": "sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA=="
},
"node_modules/@types/node": {
"version": "18.7.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.14.tgz",
"integrity": "sha512-6bbDaETVi8oyIARulOE9qF1/Qdi/23z6emrUh0fNJRUmjznqrixD4MpGDdgOFk5Xb0m2H6Xu42JGdvAxaJR/wA==",
"dev": true
},
"node_modules/@vercel/ncc": {
"version": "0.34.0",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==",
"dev": true,
"bin": {
"ncc": "dist/ncc/cli.js"
}
},
"node_modules/tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==",
"engines": {
"node": ">=0.6.11 <=0.7.0 || >=0.7.3"
}
},
"node_modules/typescript": {
"version": "4.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"bin": {
"uuid": "dist/bin/uuid"
}
}
},
"dependencies": {
"@actions/core": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz",
"integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==",
"requires": {
"@actions/http-client": "^2.0.1",
"uuid": "^8.3.2"
}
},
"@actions/exec": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz",
"integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==",
"requires": {
"@actions/io": "^1.0.1"
}
},
"@actions/http-client": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
"requires": {
"tunnel": "^0.0.6"
}
},
"@actions/io": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.1.tgz",
"integrity": "sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA=="
},
"@types/node": {
"version": "18.7.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.14.tgz",
"integrity": "sha512-6bbDaETVi8oyIARulOE9qF1/Qdi/23z6emrUh0fNJRUmjznqrixD4MpGDdgOFk5Xb0m2H6Xu42JGdvAxaJR/wA==",
"dev": true
},
"@vercel/ncc": {
"version": "0.34.0",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.34.0.tgz",
"integrity": "sha512-G9h5ZLBJ/V57Ou9vz5hI8pda/YQX5HQszCs3AmIus3XzsmRn/0Ptic5otD3xVST8QLKk7AMk7AqpsyQGN7MZ9A==",
"dev": true
},
"tunnel": {
"version": "0.0.6",
"resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz",
"integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg=="
},
"typescript": {
"version": "4.8.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.2.tgz",
"integrity": "sha512-C0I1UsrrDHo2fYI5oaCGbSejwX4ch+9Y5jTQELvovfmFkK3HHSZJB8MSJcWLmCUBzQBchCrZ9rMRV6GuNrvGtw==",
"dev": true
},
"uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
}
}
}

37
package.json Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "load-secrets-action",
"version": "1.1.0",
"description": "Load Secrets from 1Password",
"main": "dist/index.js",
"directories": {
"test": "tests"
},
"scripts": {
"build": "ncc build src/index.ts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/1Password/load-secrets-action.git"
},
"keywords": [
"actions",
"1password",
"load secrets",
"connect"
],
"author": "1Password",
"license": "MIT",
"bugs": {
"url": "https://github.com/1Password/load-secrets-action/issues"
},
"homepage": "https://github.com/1Password/load-secrets-action#readme",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/exec": "^1.1.1"
},
"devDependencies": {
"@types/node": "^18.7.14",
"@vercel/ncc": "^0.34.0",
"typescript": "^4.8.2"
}
}

21
src/index.ts Normal file
View File

@@ -0,0 +1,21 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import path from 'path';
async function run(): Promise<void> {
try {
const parentDir = path.resolve(__dirname, '..');
// Get action inputs
process.env.INPUT_UNSET_PREVIOUS = core.getInput('unset-previous');
process.env.INPUT_EXPORT_ENV = core.getInput('export-env');
// Execute bash script
await exec.exec(`sh -c "` + parentDir + `/entrypoint.sh"`);
} catch (error: any) {
core.setFailed(error.message);
}
}
run();

13
tsconfig.json Normal file
View File

@@ -0,0 +1,13 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"noImplicitAny": true,
"esModuleInterop": true
},
"exclude": ["node_modules"]
}