Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Add local option
Browse files Browse the repository at this point in the history
Signed-off-by: Grant Linville <[email protected]>
  • Loading branch information
g-linville committed Oct 17, 2023
1 parent 7bd0bd1 commit 8b81c4f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ Thumbs.db

# Ignore built ts files
__tests__/runner/*
lib/**/*
lib/**/*

# JetBrains config
.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ steps:
registry: ${{secrets.YOUR_REGISTRY}}
username: ${{secrets.YOUR_USERNAME}}
password: ${{secrets.YOUR_PASSWORD}}
local: false
- run: |
acorn build . # Whatever you want to do with acorn
```
Expand All @@ -26,6 +27,7 @@ steps:
| `registry` | **Required** | Registry address to login to (e.g. ghcr.io or docker.io)
| `username` | **Required** | Registry username
| `password` | **Required** | Registry password
| `local` | 'false' | Adds the `--local-storage` argument to `acorn login` if set to 'true'

# License

Expand Down
3 changes: 2 additions & 1 deletion __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ test('loginStandard calls exec', async () => {

const username = 'hello'
const password = 'world'
const local = false

await login(registry, username, password)
await login(registry, username, password, local)

expect(execSpy).toHaveBeenCalledWith(
`acorn`,
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ inputs:
password:
description: Password
required: true
local:
description: "Adds the `--local-storage` argument to `acorn login` if set to 'true'"
required: false
default: 'false'
runs:
using: 'node16'
main: 'dist/index.js'
Expand Down
7 changes: 6 additions & 1 deletion src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@ import * as exec from '@actions/exec'
export async function login(
registry: string,
username: string,
password: string
password: string,
local: boolean,
): Promise<void> {
if (!registry || !username || !password) {
throw new Error('Registry, username, and password required')
}

const args = ['login', '--password-stdin', '--username', username, registry]

if (local) {
args.push('--local-storage')
}

core.info(`Logging into ${registry}...`)

const res = await exec.getExecOutput('acorn', args, {
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ async function setup(): Promise<void> {
const registry = core.getInput('registry')
const username = core.getInput('username')
const password = core.getInput('password')
const local= core.getInput('local') === 'true'

core.saveState('registry', registry)
await login(registry, username, password)
await login(registry, username, password, local)
}

async function teardown(): Promise<void> {
Expand Down

0 comments on commit 8b81c4f

Please sign in to comment.