Skip to content

Commit

Permalink
add app auth
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinbuhmann committed Sep 15, 2020
1 parent 21dc310 commit c74de88
Showing 9 changed files with 14,570 additions and 11,015 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -105,6 +105,12 @@ Refer [here](https://github.com/actions/checkout/blob/v1/README.md) for previous
#
# Default: false
submodules: ''

# GitHub app id
app-id: ''

# GitHub app private key
app-private-key: ''
```
<!-- end usage -->
27 changes: 14 additions & 13 deletions __test__/input-helper.test.ts
Original file line number Diff line number Diff line change
@@ -67,8 +67,8 @@ describe('input-helper tests', () => {
jest.restoreAllMocks()
})

it('sets defaults', () => {
const settings: IGitSourceSettings = inputHelper.getInputs()
it('sets defaults', async () => {
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings).toBeTruthy()
expect(settings.authToken).toBeFalsy()
expect(settings.clean).toBe(true)
@@ -82,11 +82,11 @@ describe('input-helper tests', () => {
expect(settings.repositoryPath).toBe(gitHubWorkspace)
})

it('qualifies ref', () => {
it('qualifies ref', async () => {
let originalRef = github.context.ref
try {
github.context.ref = 'some-unqualified-ref'
const settings: IGitSourceSettings = inputHelper.getInputs()
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings).toBeTruthy()
expect(settings.commit).toBe('1234567890123456789012345678901234567890')
expect(settings.ref).toBe('refs/heads/some-unqualified-ref')
@@ -97,29 +97,30 @@ describe('input-helper tests', () => {

it('requires qualified repo', () => {
inputs.repository = 'some-unqualified-repo'
assert.throws(() => {
inputHelper.getInputs()
}, /Invalid repository 'some-unqualified-repo'/)
assert.rejects(
() => inputHelper.getInputs(),
/Invalid repository 'some-unqualified-repo'/
)
})

it('roots path', () => {
it('roots path', async () => {
inputs.path = 'some-directory/some-subdirectory'
const settings: IGitSourceSettings = inputHelper.getInputs()
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.repositoryPath).toBe(
path.join(gitHubWorkspace, 'some-directory', 'some-subdirectory')
)
})

it('sets ref to empty when explicit sha', () => {
it('sets ref to empty when explicit sha', async () => {
inputs.ref = '1111111111222222222233333333334444444444'
const settings: IGitSourceSettings = inputHelper.getInputs()
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.ref).toBeFalsy()
expect(settings.commit).toBe('1111111111222222222233333333334444444444')
})

it('sets sha to empty when explicit ref', () => {
it('sets sha to empty when explicit ref', async () => {
inputs.ref = 'refs/heads/some-other-ref'
const settings: IGitSourceSettings = inputHelper.getInputs()
const settings: IGitSourceSettings = await inputHelper.getInputs()
expect(settings.ref).toBe('refs/heads/some-other-ref')
expect(settings.commit).toBeFalsy()
})
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -68,6 +68,12 @@ inputs:
When the `ssh-key` input is not provided, SSH URLs beginning with `git@github.com:` are
converted to HTTPS.
default: false
app-id:
description: GitHub app id
optional: true
app-private-key:
description: GitHub app private key
optional: true
runs:
using: node12
main: dist/index.js
Loading
Oops, something went wrong.

0 comments on commit c74de88

Please sign in to comment.