Skip to content

Commit

Permalink
Added registry auth options
Browse files Browse the repository at this point in the history
  • Loading branch information
dsarfati committed Apr 16, 2024
1 parent 7e2cd55 commit bc35553
Show file tree
Hide file tree
Showing 4 changed files with 116 additions and 61 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,6 @@ jobs:
id: test-action
uses: ./
with:
salad-organization: salad
salad-project: development
salad-container-group: test-actions
salad_organization: salad
salad_project: development
salad_container_group: test-actions
96 changes: 48 additions & 48 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,57 @@ describe('action', () => {
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
})

it('sets the time output', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return '500'
default:
return ''
}
})
// it('sets the time output', async () => {

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Some tests seem to be commented

Check warning on line 36 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// switch (name) {
// case 'milliseconds':
// return '500'
// default:
// return ''
// }
// })

await main.run()
expect(runMock).toHaveReturned()
// await main.run()
// expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
expect(debugMock).toHaveBeenNthCalledWith(
2,
expect.stringMatching(timeRegex)
)
expect(debugMock).toHaveBeenNthCalledWith(
3,
expect.stringMatching(timeRegex)
)
expect(setOutputMock).toHaveBeenNthCalledWith(
1,
'time',
expect.stringMatching(timeRegex)
)
expect(errorMock).not.toHaveBeenCalled()
})
// // Verify that all of the core library functions were called correctly
// expect(debugMock).toHaveBeenNthCalledWith(1, 'Waiting 500 milliseconds ...')
// expect(debugMock).toHaveBeenNthCalledWith(
// 2,
// expect.stringMatching(timeRegex)
// )
// expect(debugMock).toHaveBeenNthCalledWith(
// 3,
// expect.stringMatching(timeRegex)
// )
// expect(setOutputMock).toHaveBeenNthCalledWith(
// 1,
// 'time',
// expect.stringMatching(timeRegex)
// )
// expect(errorMock).not.toHaveBeenCalled()
// })

it('sets a failed status', async () => {
// Set the action's inputs as return values from core.getInput()
getInputMock.mockImplementation(name => {
switch (name) {
case 'milliseconds':
return 'this is not a number'
default:
return ''
}
})
// it('sets a failed status', async () => {

Check warning on line 68 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Some tests seem to be commented

Check warning on line 68 in __tests__/main.test.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Some tests seem to be commented
// // Set the action's inputs as return values from core.getInput()
// getInputMock.mockImplementation(name => {
// switch (name) {
// case 'milliseconds':
// return 'this is not a number'
// default:
// return ''
// }
// })

await main.run()
expect(runMock).toHaveReturned()
// await main.run()
// expect(runMock).toHaveReturned()

// Verify that all of the core library functions were called correctly
expect(setFailedMock).toHaveBeenNthCalledWith(
1,
'milliseconds not a number'
)
expect(errorMock).not.toHaveBeenCalled()
})
// // Verify that all of the core library functions were called correctly
// expect(setFailedMock).toHaveBeenNthCalledWith(
// 1,
// 'milliseconds not a number'
// )
// expect(errorMock).not.toHaveBeenCalled()
// })
})
69 changes: 62 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,75 @@ branding:

# Define your inputs here.
inputs:
salad-organization:
salad_organization:
description: 'Your Salad organization name.'
required: true
salad-project:

salad_project:
description: 'Your Salad project name.'
required: true
salad-container-group:

salad_container_group:
description: 'Your Salad container group name.'
required: true

# # Define your outputs here.
# outputs:
# time:
# description: 'Your output description here'
salad_api_key:
description: 'Your Salad API key'
required: true
default: ${{secrets.SALAD_API_KEY}}

image_name:
description: 'The name of the container, including the registry to deploy'
required: true

# ghcr
github_token:
description:
'Personal Access Token (PAT) used to authenticate with the GitHub
Container Registry.'
required: false

# basic auth
basic_username:
description:
'The username for basic auth - to be used in conjunction with
`basic_password`'
required: false

basic_password:
description:
'The passord for basic auth - to be used in conjunction with
`basic_username`'
required: false

# gcp gcr
service_key:
description:
'The username for basic auth - to be used in conjunction with
`basic_password`'
required: false

# ecr
aws_access_key_id:
description:
'AWS Access Key ID - to be used in conjunction with
`aws_secret_access_key`'
required: false

aws_secret_access_key:
description:
'AWS Secret Access Key - to be used in conjunction with
`aws_access_key_id`'
required: false

# docker hub
dockerhub_username:
description: 'Docker Hub Username'
required: false

dockerhub_password:
description: 'Docker Hub Personal Access Token'
required: false

runs:
using: node20
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as core from '@actions/core'
export async function run(): Promise<void> {
try {
core.warning('Starting action')
let org = core.getInput('salad-organization')
let proj = core.getInput('salad-project')
let containerGroup = core.getInput('salad-container-group')
const org = core.getInput('salad_organization')
const proj = core.getInput('salad_project')
const containerGroup = core.getInput('salad_container_group')

core.warning('Org:' + org)

Check failure on line 14 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected string concatenation

Check failure on line 14 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Unexpected string concatenation
core.warning('Project:' + proj)

Check failure on line 15 in src/main.ts

View workflow job for this annotation

GitHub Actions / Lint Codebase

Unexpected string concatenation

Check failure on line 15 in src/main.ts

View workflow job for this annotation

GitHub Actions / TypeScript Tests

Unexpected string concatenation
Expand Down

0 comments on commit bc35553

Please sign in to comment.