Skip to content

Commit e6b7cd3

Browse files
committed
migrate to onepassword version 2.30.0
1 parent 698bb96 commit e6b7cd3

File tree

8 files changed

+51
-56
lines changed

8 files changed

+51
-56
lines changed

.github/workflows/test.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
npm install
1717
- run: |
1818
npm run all
19-
test: # make sure the action works on a clean machine without building
19+
test: # make sure the action works
2020
strategy:
2121
matrix:
2222
runs-on: [macos-latest, ubuntu-20.04, ubuntu-22.04, ubuntu-latest]
@@ -30,6 +30,10 @@ jobs:
3030
- name: Checkout Github
3131
uses: actions/checkout@v3
3232
if: ${{ !env.ACT }}
33+
- name: Install dependencies
34+
run: npm install
35+
- name: Build Typescript
36+
run: npm run all
3337
- name: Test Action
3438
uses: ./
3539
id: secrets

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 3.0.0
2+
3+
- Migrated from 1Password CLI version 1.8.0 to 2.30.0
4+
15
## 2.1.0
26

37
- Support for multi word names. Resolves [#54](https://github.com/RobotsAndPencils/1password-action/issues/54)

__tests__/parsing.test.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,19 @@ test('parses multiple unquoted, renamed items', async () => {
4242
})
4343

4444
test('parses single unquoted multi word item', async () => {
45-
const output = parseItemRequestsInput('GitHub Action Test Vault > Test Login Four Words')
45+
const output = parseItemRequestsInput(
46+
'GitHub Action Test Vault > Test Login Four Words'
47+
)
4648
expect(output).toHaveLength(1)
4749
expect(output[0].vault).toBe('GitHub Action Test Vault')
4850
expect(output[0].name).toBe('Test Login Four Words')
4951
expect(output[0].outputName).toBe('test_login_four_words')
5052
})
5153

5254
test('parses single unquoted multi word item separated by periods', async () => {
53-
const output = parseItemRequestsInput('GitHub Action Test Vault > Test.Login.Four.Words')
55+
const output = parseItemRequestsInput(
56+
'GitHub Action Test Vault > Test.Login.Four.Words'
57+
)
5458
expect(output).toHaveLength(1)
5559
expect(output[0].vault).toBe('GitHub Action Test Vault')
5660
expect(output[0].name).toBe('Test.Login.Four.Words')

dist/index.js

+16-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/1password.ts

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {install} from './install'
33
import * as tc from '@actions/tool-cache'
44
import {execWithOutput} from './exec'
55

6-
const ONE_PASSWORD_VERSION = '1.8.0'
6+
const ONE_PASSWORD_VERSION = '2.30.0'
77

88
export class OnePassword {
99
onePasswordEnv: {[key: string]: string}
@@ -37,13 +37,18 @@ export class OnePassword {
3737
const output = await execWithOutput(
3838
'op',
3939
[
40-
'signin',
40+
'account',
41+
'add',
42+
'--address',
4143
signInAddress,
44+
'--email',
4245
emailAddress,
46+
'--secret-key',
4347
secretKey,
4448
'--raw',
4549
'--shorthand',
46-
'github_action'
50+
'github_action',
51+
'--signin'
4752
],
4853
{
4954
env,
@@ -67,14 +72,14 @@ export class OnePassword {
6772
async listItemsInVault(vault: string): Promise<string> {
6873
const env = this.onePasswordEnv
6974

70-
return await execWithOutput('op', ['list', 'items', '--vault', vault], {
75+
return await execWithOutput('op', ['item', 'list', '--vault', vault, 'format=json'], {
7176
env
7277
})
7378
}
7479

7580
async getItemInVault(vault: string, uuid: string): Promise<string> {
7681
const env = this.onePasswordEnv
77-
return await execWithOutput('op', ['get', 'item', uuid, '--vault', vault], {
82+
return await execWithOutput('op', ['item', 'get', uuid, '--vault', vault, 'format=json'], {
7883
env
7984
})
8085
}
@@ -83,7 +88,7 @@ export class OnePassword {
8388
const env = this.onePasswordEnv
8489
await execWithOutput(
8590
'op',
86-
['get', 'document', uuid, '--output', filename],
91+
['document', 'get', uuid, '--output', filename],
8792
{
8893
env
8994
}
@@ -92,6 +97,6 @@ export class OnePassword {
9297

9398
async signOut(): Promise<void> {
9499
const env = this.onePasswordEnv
95-
await execWithOutput('op', ['signout', '--forget'], {env})
100+
await execWithOutput('op', ['account', 'forget'], {env})
96101
}
97102
}

src/install.ts

+6-30
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,24 @@ import {mv} from '@actions/io'
44
import {chmod} from '@actions/io/lib/io-util'
55
import * as tc from '@actions/tool-cache'
66
import * as exec from '@actions/exec'
7-
import {execWithOutput} from './exec'
87

9-
const CERT_IDENTIFIER = 'Developer ID Installer: AgileBits Inc. (2BUA8C4S2C)'
108
const KEY_FINGERPRINT = '3FEF9748469ADBE15DA7CA80AC2D62742012EA22'
119

1210
export async function install(onePasswordVersion: string): Promise<void> {
1311
const platform = os.platform().toLowerCase()
1412

15-
let extension = 'zip'
13+
let arch = 'amd64'
1614
if (platform === 'darwin') {
17-
extension = 'pkg'
15+
arch = 'arm64'
1816
}
19-
const onePasswordUrl = `https://cache.agilebits.com/dist/1P/op/pkg/v${onePasswordVersion}/op_${platform}_amd64_v${onePasswordVersion}.${extension}`
20-
const archive = await tc.downloadTool(onePasswordUrl)
17+
const onePasswordUrl = `https://cache.agilebits.com/dist/1P/op2/pkg/v${onePasswordVersion}/op_${platform}_${arch}_v${onePasswordVersion}.zip`
2118
core.info(
2219
`Downloading ${onePasswordVersion} for ${platform} from ${onePasswordUrl}`
2320
)
21+
const archive = await tc.downloadTool(onePasswordUrl)
22+
const extracted = await tc.extractZip(archive)
2423

25-
let extracted: string
26-
if (platform === 'darwin') {
27-
const signatureCheck = await execWithOutput('pkgutil', [
28-
'--check-signature',
29-
archive
30-
])
31-
if (signatureCheck.includes(CERT_IDENTIFIER) === false) {
32-
throw new Error(
33-
`Signature verification of the installer package downloaded from ${onePasswordUrl} failed.\nExpecting it to include ${CERT_IDENTIFIER}.\nReceived:\n${signatureCheck}`
34-
)
35-
} else {
36-
core.info('Verified the code signature of the installer package.')
37-
}
38-
39-
// Expanding the package manually to avoid needing an admin password for installation and to be able to put it into the tool cache.
40-
const destination = 'op.unpkg'
41-
await exec.exec('pkgutil', ['--expand', archive, destination])
42-
await exec.exec(
43-
`/bin/bash -c "cat ${destination}/Payload | gzip -d | cpio -id"`
44-
)
45-
extracted = '.'
46-
} else {
47-
extracted = await tc.extractZip(archive)
48-
24+
if (platform !== 'darwin') {
4925
await exec.exec('gpg', [
5026
'--keyserver',
5127
'keyserver.ubuntu.com',

src/main.ts

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ async function run(): Promise<void> {
3434
core.setSecret(secretKey)
3535

3636
core.startGroup('Signing in to 1Password')
37+
3738
try {
3839
await onePassword.signIn(
3940
signInAddress,

0 commit comments

Comments
 (0)