Skip to content

Commit

Permalink
Add action secrets as input (#14)
Browse files Browse the repository at this point in the history
* feat: action-secrets-as-input

* fix action

* fix: action test

* fix: action input from CI.yml

* fix:  action.yml

* fix: delete output

* fix: error Lint

---------

Co-authored-by: theocdl <theoclaudel@outlook.com>
  • Loading branch information
julienbrg and theocdl authored Jan 29, 2024
1 parent f22aa8d commit 8007a1b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 11 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ jobs:
id: test-action
uses: ./
with:
milliseconds: 2000
ISSUE_NUMBER: 1
PRIVATE_KEY: ${{ secrets.WALLET_OWNER_PRIVATE_KEY }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
# - name: Print Output
# id: output
# run: echo "${{ steps.test-action.outputs.time }}"
15 changes: 15 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,29 @@ import * as main from '../src/main'
const runMock = jest.spyOn(main, 'run')

let errorMock: jest.SpyInstance
let getInputMock: jest.SpyInstance

describe('action', () => {
beforeEach(() => {
jest.clearAllMocks()

errorMock = jest.spyOn(core, 'error').mockImplementation()
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
})
// a refaire en ajoutant "getInputMock = jest.spyOn(core, 'getInput').mockImplementation()""

it('sets the time output', async () => {
getInputMock.mockImplementation((name: string): string => {
switch (name) {
case 'ISSUE_NUMBER':
return '1'
case 'PRIVATE_KEY':
return '0x123456789'
default:
return ''
}
})

await main.run()
expect(runMock).toHaveReturned()
expect(errorMock).not.toHaveBeenCalled()
Expand Down
13 changes: 7 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ branding:
color: 'blue'

inputs:
milliseconds:
description: 'Your input description here'
ISSUE_NUMBER:
description: 'The issue number to reward.'
required: true
PRIVATE_KEY:
description: 'The private key to use to authenticate with GitHub'
required: true
default: '1000'

outputs:
time:
description: 'Your output description here'

runs:
using: node20
main: dist/index.js


2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ import { ethers } from 'ethers'
*/
export async function run(): Promise<void> {
try {
const issue_number: string = core.getInput('ISSUE_NUMBER')
const private_key: string = core.getInput('PRIVATE_KEY')

//complete Here
console.log('issue_number:', issue_number)
console.log('private_key:', private_key)

const provider = new ethers.JsonRpcProvider(
'https://ethereum-sepolia.publicnode.com'
)
Expand Down

0 comments on commit 8007a1b

Please sign in to comment.