Skip to content

Commit

Permalink
feat: initial work on the actoin
Browse files Browse the repository at this point in the history
  • Loading branch information
loispostula committed Dec 5, 2023
1 parent 9ca00b5 commit 09f1c3a
Show file tree
Hide file tree
Showing 7 changed files with 862 additions and 60 deletions.
6 changes: 3 additions & 3 deletions __tests__/wait.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
* Unit tests for src/wait.ts
*/

import { wait } from '../src/wait'
import { utils } from '../src/utils'
import { expect } from '@jest/globals'

describe('wait.ts', () => {
it('throws an invalid number', async () => {
const input = parseInt('foo', 10)
expect(isNaN(input)).toBe(true)

await expect(wait(input)).rejects.toThrow('milliseconds not a number')
await expect(utils(input)).rejects.toThrow('milliseconds not a number')
})

it('waits with a valid number', async () => {
const start = new Date()
await wait(500)
await utils(500)
const end = new Date()

const delta = Math.abs(end.getTime() - start.getTime())
Expand Down
54 changes: 46 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,56 @@
name: 'The name of your action here'
description: 'Provide a description here'
author: 'Your name or organization here'
name: 'workflow-dispatch-and-wait'
description: 'Action to dispatch and workflow and wait for its result'
author: 'ForesightMiningSoftwareCorporation'

# Add your action's branding here. This will appear on the GitHub Marketplace.
branding:
icon: 'heart'
color: 'red'
icon: 'loader'
color: 'blue'

# Define your inputs here.
inputs:
milliseconds:
description: 'Your input description here'
max_retry:
description: 'Number of retries for API calls'
default: "7"
required: false

interval:
description: 'Interval between retries (in seconds)'
default: '60'
required: false

github_token:
description: 'GitHub token for authentication'
required: true

workflow_owner:
description: 'Owner of the workflow to dispatch'
required: false

workflow_repo:
description: 'Repository of the workflow exists to dispatch'
required: true
default: '1000'

workflow_id:
description: 'ID of the workflow to be triggered (Usually the file name, e.g. `release.yaml`)'
required: true

workflow_inputs:
description: 'JSON encoded inputs for the triggered workflow'
required: false
default: '{}'

dispatch_name:
description: 'Name for the workflow run, if not set, the latest run will be fetch'
required: false

artifact_name:
description: 'Name for the artifact that the target workflow will generate'
required: false

download_path:
description: 'Where to download the artifact to'
required: false

# Define your outputs here.
outputs:
Expand Down
Loading

0 comments on commit 09f1c3a

Please sign in to comment.