Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
OR13 committed Aug 10, 2024
1 parent 8649418 commit 78d77ac
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate Private Key
- name: Private Key
id: generate_private_key
uses: ./
with:
transmute: |
jose keygen --alg ES256 --verbose
- name: Log Private Key
jose keygen --alg ES256 --verbose --output ./private.sig.jwk.json
- name: Attempt to Log Private Key
run: echo "${{ steps.generate_private_key.outputs.json }}"
- name: Public Key
id: extract_public_key
uses: ./
with:
transmute: |
jose jose keypub ./private.sig.jwk.json --output ./public.sig.jwk.json
- name: Log Public Key
run: cat ./public.sig.jwk.json
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

25 changes: 14 additions & 11 deletions src/jose/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const handler = async function ({ positionals, values }: Arguments) {
const operation = positionals.shift()
switch (operation) {
case 'keygen': {
const output = values.output
const alg = values.alg || 'ES256'
const crv = values.crv || 'Ed25519'
const verbose = values.verbose || false
Expand All @@ -32,18 +33,21 @@ export const handler = async function ({ positionals, values }: Arguments) {
const message = `🔑 ${privateKey.kid}`
debug(message)
}
const output = prettyKey(privateKey)
if (output) {
fs.writeFileSync(output, JSON.stringify(prettyKey(privateKey), null, 2))
}
if (env.github()) {
if (output.d) {
setSecret(output.d)
if (privateKey.d) {
setSecret(privateKey.d)
}
setOutput('json', output)
setOutput('json', prettyKey(privateKey))
} else {
console.log(JSON.stringify(output, null, 2))
console.log(JSON.stringify(prettyKey(privateKey), null, 2))
}
break
}
case 'keypub': {
const output = values.output
const verbose = values.verbose || false
const [pathToPrivateKey] = positionals
const privateKey = JSON.parse(fs.readFileSync(pathToPrivateKey).toString()) as jose.JWK
Expand All @@ -57,14 +61,13 @@ export const handler = async function ({ positionals, values }: Arguments) {
const message = `🔑 ${publicKey.kid}`
debug(message)
}
const output = prettyKey(publicKey)
if (output) {
fs.writeFileSync(output, JSON.stringify(publicKey, null, 2))
}
if (env.github()) {
if (output.d) {
setSecret(output.d)
}
setOutput('json', output)
setOutput('json', publicKey)
} else {
console.log(JSON.stringify(output, null, 2))
console.log(JSON.stringify(publicKey, null, 2))
}
break
}
Expand Down

0 comments on commit 78d77ac

Please sign in to comment.